#### Archived

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

# Compiling error with std::map

This topic is 5966 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## 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 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 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 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

Riley

1. 1
Rutin
24
2. 2
3. 3
4. 4
JoeJ
18
5. 5

• 14
• 14
• 11
• 11
• 9
• ### Forum Statistics

• Total Topics
631757
• Total Posts
3002142
×