Ich habe einen folgenden Code tun:Karte von Vektoren - wie es
std::map<std::wstring, std::vector<Table> > my_map;
my_map[L"abc"].push_back(Table());
aber versuchen, es zu kompilieren es eine Menge Fehler {MSVC 2010} gibt, die ich nicht verstehe überhaupt nicht.
Also, eine rhetorische Frage: Warum MS gibt eine Reihe von Fehlern, die Menschen nicht verstehen können? Und zweitens: Wie repariere ich die zweite Zeile?
Vielen Dank.
Hier sind die Fehler für das Bezug:
2>c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\xfunctional(125): error C2784: 'bool std::operator <(const std::vector<_Ty,_Ax> &,const std::vector<_Ty,_Ax> &)' : could not deduce template argument for 'const std::vector<_Ty,_Ax> &' from 'const std::wstring'
2> c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\vector(1502) : see declaration of 'std::operator <'
2> c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\xfunctional(124) : while compiling class template member function 'bool std::less<_Ty>::operator()(const _Ty &,const _Ty &) const'
2> with
2> [
2> _Ty=std::wstring
2> ]
2> c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\map(71) : see reference to class template instantiation 'std::less<_Ty>' being compiled
2> with
2> [
2> _Ty=std::wstring
2> ]
2> c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\xtree(451) : see reference to class template instantiation 'std::_Tmap_traits<_Kty,_Ty,_Pr,_Alloc,_Mfl>' being compiled
2> with
2> [
2> _Kty=std::wstring,
2> _Ty=std::vector<Table>,
2> _Pr=std::less<std::wstring>,
2> _Alloc=std::allocator<std::pair<const std::wstring,std::vector<Table>>>,
2> _Mfl=false
2> ]
2> c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\xtree(520) : see reference to class template instantiation 'std::_Tree_nod<_Traits>' being compiled
2> with
2> [
2> _Traits=std::_Tmap_traits<std::wstring,std::vector<Table>,std::less<std::wstring>,std::allocator<std::pair<const std::wstring,std::vector<Table>>>,false>
2> ]
2> c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\xtree(659) : see reference to class template instantiation 'std::_Tree_val<_Traits>' being compiled
2> with
2> [
2> _Traits=std::_Tmap_traits<std::wstring,std::vector<Table>,std::less<std::wstring>,std::allocator<std::pair<const std::wstring,std::vector<Table>>>,false>
2> ]
2> c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\map(81) : see reference to class template instantiation 'std::_Tree<_Traits>' being compiled
2> with
2> [
2> _Traits=std::_Tmap_traits<std::wstring,std::vector<Table>,std::less<std::wstring>,std::allocator<std::pair<const std::wstring,std::vector<Table>>>,false>
2> ]
2> C:\Users\Igor\OneDrive\Documents\dbhandler_app\dbinterface\database.h(115) : see reference to class template instantiation 'std::map<_Kty,_Ty>' being compiled
2> with
2> [
2> _Kty=std::wstring,
2> _Ty=std::vector<Table>
2> ]
2>c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\xfunctional(125): error C2784: 'bool std::operator <(const std::vector<_Ty,_Ax> &,const std::vector<_Ty,_Ax> &)' : could not deduce template argument for 'const std::vector<_Ty,_Ax> &' from 'const std::wstring'
2> c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\vector(1502) : see declaration of 'std::operator <'
2>c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\xfunctional(125): error C2784: 'bool std::operator <(const std::vector<_Ty,_Ax> &,const std::vector<_Ty,_Ax> &)' : could not deduce template argument for 'const std::vector<_Ty,_Ax> &' from 'const std::wstring'
2> c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\vector(1502) : see declaration of 'std::operator <'
2>c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\xfunctional(125): 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::wstring'
2> c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\xtree(1885) : see declaration of 'std::operator <'
2>c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\xfunctional(125): 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::wstring'
2> c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\xtree(1885) : see declaration of 'std::operator <'
2>c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\xfunctional(125): 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::wstring'
2> c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\xtree(1885) : see declaration of 'std::operator <'
2>c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\xfunctional(125): error C2784: 'bool std::operator <(const std::unique_ptr<_Ty,_Dx> &,const std::unique_ptr<_Ty2,_Dx2> &)' : could not deduce template argument for 'const std::unique_ptr<_Ty,_Dx> &' from 'const std::wstring'
2> c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\memory(2582) : see declaration of 'std::operator <'
2>c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\xfunctional(125): error C2784: 'bool std::operator <(const std::unique_ptr<_Ty,_Dx> &,const std::unique_ptr<_Ty2,_Dx2> &)' : could not deduce template argument for 'const std::unique_ptr<_Ty,_Dx> &' from 'const std::wstring'
2> c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\memory(2582) : see declaration of 'std::operator <'
2>c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\xfunctional(125): error C2784: 'bool std::operator <(const std::unique_ptr<_Ty,_Dx> &,const std::unique_ptr<_Ty2,_Dx2> &)' : could not deduce template argument for 'const std::unique_ptr<_Ty,_Dx> &' from 'const std::wstring'
2> c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\memory(2582) : see declaration of 'std::operator <'
2>c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\xfunctional(125): error C2784: 'bool std::operator <(const std::reverse_iterator<_RanIt> &,const std::reverse_iterator<_RanIt2> &)' : could not deduce template argument for 'const std::reverse_iterator<_RanIt> &' from 'const std::wstring'
2> c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\xutility(1356) : see declaration of 'std::operator <'
2>c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\xfunctional(125): error C2784: 'bool std::operator <(const std::reverse_iterator<_RanIt> &,const std::reverse_iterator<_RanIt2> &)' : could not deduce template argument for 'const std::reverse_iterator<_RanIt> &' from 'const std::wstring'
2> c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\xutility(1356) : see declaration of 'std::operator <'
2>c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\xfunctional(125): error C2784: 'bool std::operator <(const std::reverse_iterator<_RanIt> &,const std::reverse_iterator<_RanIt2> &)' : could not deduce template argument for 'const std::reverse_iterator<_RanIt> &' from 'const std::wstring'
2> c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\xutility(1356) : see declaration of 'std::operator <'
2>c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\xfunctional(125): error C2784: 'bool std::operator <(const std::_Revranit<_RanIt,_Base> &,const std::_Revranit<_RanIt2,_Base2> &)' : could not deduce template argument for 'const std::_Revranit<_RanIt,_Base> &' from 'const std::wstring'
2> c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\xutility(1179) : see declaration of 'std::operator <'
2>c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\xfunctional(125): error C2784: 'bool std::operator <(const std::_Revranit<_RanIt,_Base> &,const std::_Revranit<_RanIt2,_Base2> &)' : could not deduce template argument for 'const std::_Revranit<_RanIt,_Base> &' from 'const std::wstring'
2> c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\xutility(1179) : see declaration of 'std::operator <'
2>c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\xfunctional(125): error C2784: 'bool std::operator <(const std::_Revranit<_RanIt,_Base> &,const std::_Revranit<_RanIt2,_Base2> &)' : could not deduce template argument for 'const std::_Revranit<_RanIt,_Base> &' from 'const std::wstring'
2> c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\xutility(1179) : see declaration of 'std::operator <'
2>c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\xfunctional(125): error C2784: 'bool std::operator <(const std::pair<_Ty1,_Ty2> &,const std::pair<_Ty1,_Ty2> &)' : could not deduce template argument for 'const std::pair<_Ty1,_Ty2> &' from 'const std::wstring'
2> c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\utility(318) : see declaration of 'std::operator <'
2>c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\xfunctional(125): error C2784: 'bool std::operator <(const std::pair<_Ty1,_Ty2> &,const std::pair<_Ty1,_Ty2> &)' : could not deduce template argument for 'const std::pair<_Ty1,_Ty2> &' from 'const std::wstring'
2> c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\utility(318) : see declaration of 'std::operator <'
2>c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\xfunctional(125): error C2784: 'bool std::operator <(const std::pair<_Ty1,_Ty2> &,const std::pair<_Ty1,_Ty2> &)' : could not deduce template argument for 'const std::pair<_Ty1,_Ty2> &' from 'const std::wstring'
2> c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\utility(318) : see declaration of 'std::operator <'
2>c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\xfunctional(125): error C2676: binary '<' : 'const std::wstring' does not define this operator or a conversion to a type acceptable to the predefined operator
Haben Sie 'vector' und' map' eingeschlossen? – Rakete1111
http://StackOverflow.com/Help/Mcve –
Ich kann Ihnen versichern, dass Microsofts Compiler nicht die einzigen C++ - Compiler sind, die jede Ausrede nehmen werden, um Sie unter einem massiven Haarballen von nicht entzifferbaren Fehlermeldungen zu begraben. –