#include <iostream>
#include <list>
#include <windows.h>
using namespace std;
int count = 0;
list<string> LngList;
BOOL CALLBACK EnumLocalesProc(LPSTR lpLocaleString)
{
char lang[10];
char ctry[10];
char isoname[20];
DWORD lcid;
sscanf_s(lpLocaleString, "%X", &lcid);
GetLocaleInfo(lcid, LOCALE_SISO3166CTRYNAME, ctry, sizeof(ctry));
GetLocaleInfo(lcid, LOCALE_SISO639LANGNAME, lang, sizeof(lang));
sprintf_s(isoname, "%s-%s", lang, ctry);
LngList.push_back(isoname);
return TRUE;
}
int _tmain(int argc, char* argv[])
{
EnumSystemLocales(&EnumLocalesProc, LCID_SUPPORTED);
LngList.sort();
return 0;
}
Ошибки компиляции с STL
Пытаюсь скомпилировать следующий код:
Код:
В итоге получаю аж 17 ошибок:
Код:
C:\Program Files\Microsoft Visual Studio 9.0\VC\include\list(993) : error C2784: 'bool std::operator <(const std::list<_Ty,_Ax> &,const std::list<_Ty,_Ax> &)' : could not deduce template argument for 'const std::list<_Ty,_Ax> &' from 'std::basic_string<_Elem,_Traits,_Ax>'
with
[
_Elem=char,
_Traits=std::char_traits<char>,
_Ax=std::allocator<char>
]
C:\Program Files\Microsoft Visual Studio 9.0\VC\include\list(1310) : see declaration of 'std::operator <'
C:\Program Files\Microsoft Visual Studio 9.0\VC\include\list(984) : while compiling class template member function 'void std::list<_Ty>::merge(std::list<_Ty> &)'
with
[
_Ty=std::string
]
.\generator.cpp(9) : see reference to class template instantiation 'std::list<_Ty>' being compiled
with
[
_Ty=std::string
]
C:\Program Files\Microsoft Visual Studio 9.0\VC\include\list(993) : error C2784: 'bool std::operator <(const std::list<_Ty,_Ax> &,const std::list<_Ty,_Ax> &)' : could not deduce template argument for 'const std::list<_Ty,_Ax> &' from 'std::basic_string<_Elem,_Traits,_Ax>'
with
[
_Elem=char,
_Traits=std::char_traits<char>,
_Ax=std::allocator<char>
]
C:\Program Files\Microsoft Visual Studio 9.0\VC\include\list(1310) : see declaration of 'std::operator <'
C:\Program Files\Microsoft Visual Studio 9.0\VC\include\list(993) : error C2784: 'bool std::operator <(const std::list<_Ty,_Ax> &,const std::list<_Ty,_Ax> &)' : could not deduce template argument for 'const std::list<_Ty,_Ax> &' from 'std::basic_string<_Elem,_Traits,_Ax>'
with
[
_Elem=char,
_Traits=std::char_traits<char>,
_Ax=std::allocator<char>
]
C:\Program Files\Microsoft Visual Studio 9.0\VC\include\list(1310) : see declaration of 'std::operator <'
C:\Program Files\Microsoft Visual Studio 9.0\VC\include\list(993) : error C2784: 'bool std::operator <(const std::list<_Ty,_Ax> &,const std::list<_Ty,_Ax> &)' : could not deduce template argument for 'const std::list<_Ty,_Ax> &' from 'std::basic_string<_Elem,_Traits,_Ax>'
with
[
_Elem=char,
_Traits=std::char_traits<char>,
_Ax=std::allocator<char>
]
C:\Program Files\Microsoft Visual Studio 9.0\VC\include\list(1310) : see declaration of 'std::operator <'
C:\Program Files\Microsoft Visual Studio 9.0\VC\include\list(993) : 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 'std::basic_string<_Elem,_Traits,_Ax>'
with
[
_Elem=char,
_Traits=std::char_traits<char>,
_Ax=std::allocator<char>
]
C:\Program Files\Microsoft Visual Studio 9.0\VC\include\xutility(2262) : see declaration of 'std::operator <'
C:\Program Files\Microsoft Visual Studio 9.0\VC\include\list(993) : 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 'std::basic_string<_Elem,_Traits,_Ax>'
with
[
_Elem=char,
_Traits=std::char_traits<char>,
_Ax=std::allocator<char>
]
C:\Program Files\Microsoft Visual Studio 9.0\VC\include\xutility(2262) : see declaration of 'std::operator <'
C:\Program Files\Microsoft Visual Studio 9.0\VC\include\list(993) : 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 'std::basic_string<_Elem,_Traits,_Ax>'
with
[
_Elem=char,
_Traits=std::char_traits<char>,
_Ax=std::allocator<char>
]
C:\Program Files\Microsoft Visual Studio 9.0\VC\include\xutility(2262) : see declaration of 'std::operator <'
C:\Program Files\Microsoft Visual Studio 9.0\VC\include\list(993) : 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 'std::basic_string<_Elem,_Traits,_Ax>'
with
[
_Elem=char,
_Traits=std::char_traits<char>,
_Ax=std::allocator<char>
]
C:\Program Files\Microsoft Visual Studio 9.0\VC\include\xutility(2262) : see declaration of 'std::operator <'
C:\Program Files\Microsoft Visual Studio 9.0\VC\include\list(993) : 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 'std::basic_string<_Elem,_Traits,_Ax>'
with
[
_Elem=char,
_Traits=std::char_traits<char>,
_Ax=std::allocator<char>
]
C:\Program Files\Microsoft Visual Studio 9.0\VC\include\xutility(2072) : see declaration of 'std::operator <'
C:\Program Files\Microsoft Visual Studio 9.0\VC\include\list(993) : 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 'std::basic_string<_Elem,_Traits,_Ax>'
with
[
_Elem=char,
_Traits=std::char_traits<char>,
_Ax=std::allocator<char>
]
C:\Program Files\Microsoft Visual Studio 9.0\VC\include\xutility(2072) : see declaration of 'std::operator <'
C:\Program Files\Microsoft Visual Studio 9.0\VC\include\list(993) : 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 'std::basic_string<_Elem,_Traits,_Ax>'
with
[
_Elem=char,
_Traits=std::char_traits<char>,
_Ax=std::allocator<char>
]
и т.д.
with
[
_Elem=char,
_Traits=std::char_traits<char>,
_Ax=std::allocator<char>
]
C:\Program Files\Microsoft Visual Studio 9.0\VC\include\list(1310) : see declaration of 'std::operator <'
C:\Program Files\Microsoft Visual Studio 9.0\VC\include\list(984) : while compiling class template member function 'void std::list<_Ty>::merge(std::list<_Ty> &)'
with
[
_Ty=std::string
]
.\generator.cpp(9) : see reference to class template instantiation 'std::list<_Ty>' being compiled
with
[
_Ty=std::string
]
C:\Program Files\Microsoft Visual Studio 9.0\VC\include\list(993) : error C2784: 'bool std::operator <(const std::list<_Ty,_Ax> &,const std::list<_Ty,_Ax> &)' : could not deduce template argument for 'const std::list<_Ty,_Ax> &' from 'std::basic_string<_Elem,_Traits,_Ax>'
with
[
_Elem=char,
_Traits=std::char_traits<char>,
_Ax=std::allocator<char>
]
C:\Program Files\Microsoft Visual Studio 9.0\VC\include\list(1310) : see declaration of 'std::operator <'
C:\Program Files\Microsoft Visual Studio 9.0\VC\include\list(993) : error C2784: 'bool std::operator <(const std::list<_Ty,_Ax> &,const std::list<_Ty,_Ax> &)' : could not deduce template argument for 'const std::list<_Ty,_Ax> &' from 'std::basic_string<_Elem,_Traits,_Ax>'
with
[
_Elem=char,
_Traits=std::char_traits<char>,
_Ax=std::allocator<char>
]
C:\Program Files\Microsoft Visual Studio 9.0\VC\include\list(1310) : see declaration of 'std::operator <'
C:\Program Files\Microsoft Visual Studio 9.0\VC\include\list(993) : error C2784: 'bool std::operator <(const std::list<_Ty,_Ax> &,const std::list<_Ty,_Ax> &)' : could not deduce template argument for 'const std::list<_Ty,_Ax> &' from 'std::basic_string<_Elem,_Traits,_Ax>'
with
[
_Elem=char,
_Traits=std::char_traits<char>,
_Ax=std::allocator<char>
]
C:\Program Files\Microsoft Visual Studio 9.0\VC\include\list(1310) : see declaration of 'std::operator <'
C:\Program Files\Microsoft Visual Studio 9.0\VC\include\list(993) : 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 'std::basic_string<_Elem,_Traits,_Ax>'
with
[
_Elem=char,
_Traits=std::char_traits<char>,
_Ax=std::allocator<char>
]
C:\Program Files\Microsoft Visual Studio 9.0\VC\include\xutility(2262) : see declaration of 'std::operator <'
C:\Program Files\Microsoft Visual Studio 9.0\VC\include\list(993) : 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 'std::basic_string<_Elem,_Traits,_Ax>'
with
[
_Elem=char,
_Traits=std::char_traits<char>,
_Ax=std::allocator<char>
]
C:\Program Files\Microsoft Visual Studio 9.0\VC\include\xutility(2262) : see declaration of 'std::operator <'
C:\Program Files\Microsoft Visual Studio 9.0\VC\include\list(993) : 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 'std::basic_string<_Elem,_Traits,_Ax>'
with
[
_Elem=char,
_Traits=std::char_traits<char>,
_Ax=std::allocator<char>
]
C:\Program Files\Microsoft Visual Studio 9.0\VC\include\xutility(2262) : see declaration of 'std::operator <'
C:\Program Files\Microsoft Visual Studio 9.0\VC\include\list(993) : 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 'std::basic_string<_Elem,_Traits,_Ax>'
with
[
_Elem=char,
_Traits=std::char_traits<char>,
_Ax=std::allocator<char>
]
C:\Program Files\Microsoft Visual Studio 9.0\VC\include\xutility(2262) : see declaration of 'std::operator <'
C:\Program Files\Microsoft Visual Studio 9.0\VC\include\list(993) : 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 'std::basic_string<_Elem,_Traits,_Ax>'
with
[
_Elem=char,
_Traits=std::char_traits<char>,
_Ax=std::allocator<char>
]
C:\Program Files\Microsoft Visual Studio 9.0\VC\include\xutility(2072) : see declaration of 'std::operator <'
C:\Program Files\Microsoft Visual Studio 9.0\VC\include\list(993) : 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 'std::basic_string<_Elem,_Traits,_Ax>'
with
[
_Elem=char,
_Traits=std::char_traits<char>,
_Ax=std::allocator<char>
]
C:\Program Files\Microsoft Visual Studio 9.0\VC\include\xutility(2072) : see declaration of 'std::operator <'
C:\Program Files\Microsoft Visual Studio 9.0\VC\include\list(993) : 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 'std::basic_string<_Elem,_Traits,_Ax>'
with
[
_Elem=char,
_Traits=std::char_traits<char>,
_Ax=std::allocator<char>
]
и т.д.
Первый раз в жизни использую STL, т.к. до этого писал в основном на C и др. В примерах в инете всё нормально, когда пытаюсь скопировать любой пример с STL и сбилдить, тоже получаю ошибки.
Код:
list<string[highlight]*[/highlight]> LngList;
Цитата: koodeer
Всё просто:
оригинально.. но по-моему все еще чуточку проще:
Код:
#include <iostream>
#include <list>
#include <string>
#include <windows.h>
#include <list>
#include <string>
#include <windows.h>
(ну и tchar.h или main)
http://www.daniweb.com/code/snippet216363.html, по которому я делал, явно это не указано. Вот такие, блин, учебные материалы в инете)
Спасибо, Phodopus. Действительно не хватало хедера string. Странно, но в примере
Что поделать, это одна из темных сторон цпп... :)