RazzorFlame Temat założony przez niniejszego użytkownika |
Template aliasing generuje błędy » 2015-07-02 12:30:48 Witam, pisząc swój silnik chciałem by typy zmiennych lub obiektów były bardziej czytelne, dlatego stworzyłem sobie header: #include <vector> #include <string> #include <map>
typedef __int8 Int8U; typedef __int16 Int16U; typedef __int32 Int32U; typedef __int64 Int64U;
typedef float Float32U; typedef double Float64U;
typedef unsigned __int8 UInt8U; typedef unsigned __int16 UInt16U; typedef unsigned __int32 UInt32U; typedef unsigned __int64 UInt64U;
typedef std::basic_string < char, std::char_traits < char >, std::allocator < char > > StringU, NameU, TextU; typedef std::basic_string < wchar_t, std::char_traits < wchar_t >, std::allocator < wchar_t > > WideStringU, WideNameU, WideTextU;
template < typename T > using ContainerU = std::vector < T, std::allocator < T >>;
template < typename T, typename U > using AssociativeU = std::map < T, U, std::allocator < std::pair < const T, U >> >; template < typename T, typename U > using MapU = std::map < T, U, std::allocator < std::pair < const T, U >> >;
#define ClassParent(ClassParent) typedef ClassParent Super;
Konkretnie chodzi mi o ten fragment: typedef std::basic_string < char, std::char_traits < char >, std::allocator < char > > StringU, NameU, TextU; typedef std::basic_string < wchar_t, std::char_traits < wchar_t >, std::allocator < wchar_t > > WideStringU, WideNameU, WideTextU;
template < typename T > using ContainerU = std::vector < T, std::allocator < T >>;
template < typename T, typename U > using AssociativeU = std::map < T, U, std::allocator < std::pair < const T, U >> >; template < typename T, typename U > using MapU = std::map < T, U, std::allocator < std::pair < const T, U >> >;
Mam też kod ImageManager'u: class ImageManager : public WindowChild { typedef AssociativeU < WideStringU, Image *> BitmapMap; BitmapMap m_images;
Tutaj dostaję błędy: 1>C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include\map(117): error C2535: 'std::map<WideStringU,edge::draw2d::Image *,std::allocator<std::pair<const WideStringU,edge::draw2d::Image *>>,std::allocator<std::pair<const WideStringU,edge::draw2d::Image *>>>::map(const std::allocator<std::pair<const WideStringU,edge::draw2d::Image *>> &)' : member function already defined or declared 1> C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include\map(98) : see declaration of 'std::map<WideStringU,edge::draw2d::Image *,std::allocator<std::pair<const WideStringU,edge::draw2d::Image *>>,std::allocator<std::pair<const WideStringU,edge::draw2d::Image *>>>::map' 1> C:\Users\PC\Documents\Visual Studio 2013\Projekt1\Include\EDGE\Graphics\2D\edge2DImageManager.hpp(18) : see reference to class template instantiation 'std::map<WideStringU,edge::draw2d::Image *,std::allocator<std::pair<const WideStringU,edge::draw2d::Image *>>,std::allocator<std::pair<const WideStringU,edge::draw2d::Image *>>>' being compiled
Dodam, że to działa: typedef std::map < std::wstring, Image *> BitmapMap;
Dlaczego tak się dzieje? |
|
Monika90 |
» 2015-07-02 12:44:03 Trzecim parametrem std::map ma być komparator, a nie alokator. |
|
RazzorFlame Temat założony przez niniejszego użytkownika |
» 2015-07-02 12:49:12 Faktycznie, powinno być: std::map < T, U, std::less < T >, std::allocator < std::pair < const T, U >> >; |
|
Monika90 |
» 2015-07-02 12:50:45 A dlaczego po prostu nie zrobisz tak: template < typename T, typename U > using AssociativeU = std::map < T, U >;
|
|
RazzorFlame Temat założony przez niniejszego użytkownika |
» 2015-07-02 12:56:47 O ile pamiętam to jak tak robiłem wcześniej to dostawałem też błędy... Spróbuje znowu.
Edit: Faktycznie, działa. Dziękuje za pomoc. |
|
« 1 » |