I have an error while trying to use std::map with my own class as value. The definition of the map is this:
std::map<std::string,CCrossSection> Xsects;
This line compiles fine (so it kindo of works?)
Xsects[sectionId].m_vProfile.push_back(pt);
When I try to iterate over the map however:
for (std::map<std::string,CCrossSection>::iterator xs = Xsects.begin(); xs < Xsects.end(); xs++) {
it->second.SaveFile(f);
}
It gives me multiple errors similar to this:
error C2784: 'bool std::operator <(const std::_Tree<_Traits> &,const std::_Tree<_Traits> &)' : could not deduce template argument for 'const std::_Tree<_Traits> &' from 'std::_Tree<_Traits>::iterator'
with
[
_Traits=std::_Tmap_traits<std::string,CCrossSection,std::less<std::string>,std::allocator<std::pair<const std::string,CCrossSection>>,false>
]
c:\program files\microsoft visual studio 9.0\vc\include\xtree(1466) : see declaration of 'std::operator <'
I thought that it is a problem with less operator and I added it to my definition of the class CCrossSection, but it didn't change a thing. Later I read that the key of the map has to have less operator defined and I think std::string has. Any ideas why it happens?
Cheers Tomek