Got the above error, when compiling something that looked like this:
std::map<std::string, myType> myMap;
myMap[“Test”] = myType();
Looked around on the net, didn’t find the answer, thought about it for a bit and then realised I was missing #include <string> which fixed the problem. The error was a bit cryptic. Look for yourself at this dump from the compiler output:
1>C:\Program Files\Microsoft Visual Studio 8\VC\include\functional(143) : error C2784: ‘bool std::operator <(const std::_Tree<_Traits> &,const std::_Tree<_Traits> &)’ : could not deduce template argument for ‘const std::_Tree<_Traits> &’ from ‘const std::string’
1> C:\Program Files\Microsoft Visual Studio 8\VC\include\xtree(1372) : see declaration of ‘std::operator <’
1> C:\Program Files\Microsoft Visual Studio 8\VC\include\functional(142) : while compiling class template member function ‘bool std::less<_Ty>::operator ()(const _Ty &,const _Ty &) const’
1> with
1> [
1> _Ty=std::string
1> ]
1> C:\Program Files\Microsoft Visual Studio 8\VC\include\map(72) : see reference to class template instantiation ‘std::less<_Ty>’ being compiled
1> with
1> [
1> _Ty=std::string
1> ]
1> C:\Program Files\Microsoft Visual Studio 8\VC\include\xtree(26) : see reference to class template instantiation ‘std::_Tmap_traits<_Kty,_Ty,_Pr,_Alloc,_Mfl>’ being compiled
1> with
1> [
1> _Kty=std::string,
1> _Ty=std::string,
1> _Pr=std::less<std::string>,
1> _Alloc=std::allocator<std::pair<const std::string,std::string>>,
1> _Mfl=false
1> ]
1> C:\Program Files\Microsoft Visual Studio 8\VC\include\xtree(68) : see reference to class template instantiation ‘std::_Tree_nod<_Traits>’ being compiled
1> with
1> [
1> _Traits=std::_Tmap_traits<std::string,std::string,std::less<std::string>,std::allocator<std::pair<const std::string,std::string>>,false>
1> ]
1> C:\Program Files\Microsoft Visual Studio 8\VC\include\xtree(94) : see reference to class template instantiation ‘std::_Tree_ptr<_Traits>’ being compiled
1> with
1> [
1> _Traits=std::_Tmap_traits<std::string,std::string,std::less<std::string>,std::allocator<std::pair<const std::string,std::string>>,false>
1> ]
http://johnstewien.wordpress.com/2009/12/02/fixed-error-c2784-from-compiling-adding-an-entry-to-a-stdmap/