Archived

This topic is now archived and is closed to further replies.

rileyriley

Compiling error with std::map

Recommended Posts

In an effort to learn more of the STL, I've decided to use a map to link types of objects with their respective models. I thought that the following declaration would be correct:
  map<const OBJECT_TYPE, Drawable> models;   
However, when compiling, I get the following error:
  c:\Program Files\Microsoft Visual Studio .NET\Vc7\include\xmemory(87): error C2535: 'std::allocator<_Ty>::pointer std::allocator<_Ty>::address(std::allocator<_Ty>::reference) const' : member function already defined or declared
        with
        [
            _Ty=const std::_Tree<std::_Tmap_traits<const OBJECT_TYPE,Drawable,std::less<const OBJECT_TYPE>,std::allocator<std::pair<const OBJECT_TYPE,Drawable>>,false>>::key_type
        ]
      
As a matter of fact, I get that exact same error twice, on the same line. I don't know what xmemory is, and I don't really know much about the STL, so any insight more knowledgable folk could give me would be greatly appreciated. I've checked for every mistake I can think of; models is only declared once, the file that it is in is only #included once, and it has #ifndef etc directives to make sure that it is only compiled once even if it were included more than once... Thanks for any help, Riley Edit: dang these tags are tricky Edited by - rileyriley on March 20, 2002 12:06:23 PM

Share this post


Link to post
Share on other sites
You have a redeclaration error, which is unlikely to be related to your use of std::map. Either look for duplicated functions, or post a minimal compilable sample of your code.

Share this post


Link to post
Share on other sites
Yeah, your declaration looks fine except for the const in your key being redundant (it''s already const by definition of map). You must be redeclaring something as SabreMan said.

Share this post


Link to post
Share on other sites
Interestingly enough, removing the const from the declaration of models eliminated the compiler errors.. I don''t really understand why, but whatever ;x

Thanks for your help guys
Riley

Share this post


Link to post
Share on other sites