所有这些问题都包含解析和拆分std :: string而不是std :: wstring的答案和代码。
当我试图尝试进行此类转换时,我得到了以下内容:
std::wstring sql;
std::wistringstream str( sql );
std::wstring s;
while( std::getline( str, s, ',' ) )
{
}
error C2780: 'std::basic_istream<_Elem,_Traits> &std::getline(std::basic_istream<_Elem,_Traits> &,std::basic_string<_Elem,_Traits,_Alloc> &)' : expects 2 arguments - 3 provided
1> c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\string(479) : see declaration of 'std::getline'
error C2784: 'std::basic_istream<_Elem,_Traits> &std::getline(std::basic_istream<_Elem,_Traits> &,std::basic_string<_Elem,_Traits,_Alloc> &,const _Elem)' : could not deduce template argument for 'std::basic_istream<_Elem,_Traits> &' from 'std::wistringstream'
1> c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\string(468) : see declaration of 'std::getline'
error C2782: 'std::basic_istream<_Elem,_Traits> &std::getline(std::basic_istream<_Elem,_Traits> &,std::basic_string<_Elem,_Traits,_Alloc> &,const _Elem)' : template parameter '_Elem' is ambiguous
1> c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\string(468) : see declaration of 'std::getline'
1> could be 'char'
1> or 'wchar_t'
error C2780: 'std::basic_istream<_Elem,_Traits> &std::getline(std::basic_istream<_Elem,_Traits> &&,std::basic_string<_Elem,_Traits,_Alloc> &)' : expects 2 arguments - 3 provided
1> c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\string(448) : see declaration of 'std::getline'
error C2784: 'std::basic_istream<_Elem,_Traits> &std::getline(std::basic_istream<_Elem,_Traits> &&,std::basic_string<_Elem,_Traits,_Alloc> &,const _Elem)' : could not deduce template argument for 'std::basic_istream<_Elem,_Traits> &&' from 'std::wistringstream'
1> c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\string(395) : see declaration of 'std::getline'
error C2782: 'std::basic_istream<_Elem,_Traits> &std::getline(std::basic_istream<_Elem,_Traits> &&,std::basic_string<_Elem,_Traits,_Alloc> &,const _Elem)' : template parameter '_Elem' is ambiguous
1> c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\string(395) : see declaration of 'std::getline'
1> could be 'char'
1> or 'wchar_t'
fatal error C1903: unable to recover from previous error(s); stopping compilation
这是MSVC 2010。
正如我在开始时说的那样 - 这不是重复的。这个问题明确是关于std :: wstring而不是std :: string。我做错了什么?
TIA !!