我正试图为我编写的程序添加Unicode支持。我的ASCII代码已经编译并具有以下行:
我把这个转换成了:
std::stringstream stream("abc");
std::istream_iterator<std::string> it(stream);
我把这个转换成了:
std::wstringstream stream(L"abc");
std::istream_iterator<std::wstring> it(stream);
在 istream_iterator 构造函数中,我收到了以下错误:
error C2664: 'void std::vector<_Ty>::push_back(std::basic_string<_Elem,_Traits,_Alloc> &&)' : cannot convert parameter 1 from 'std::basic_string<_Elem,_Traits,_Alloc>' to 'std::basic_string<_Elem,_Traits,_Alloc> &&'
1> with
1> [
1> _Ty=std::wstring,
1> _Elem=wchar_t,
1> _Traits=std::char_traits<wchar_t>,
1> _Alloc=std::allocator<wchar_t>
1> ]
1> and
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>,
1> _Alloc=std::allocator<char>
1> ]
1> and
1> [
1> _Elem=wchar_t,
1> _Traits=std::char_traits<wchar_t>,
1> _Alloc=std::allocator<wchar_t>
1> ]
1> Reason: cannot convert from 'std::basic_string<_Elem,_Traits,_Alloc>' to 'std::basic_string<_Elem,_Traits,_Alloc>'
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>,
1> _Alloc=std::allocator<char>
1> ]
1> and
1> [
1> _Elem=wchar_t,
1> _Traits=std::char_traits<wchar_t>,
1> _Alloc=std::allocator<wchar_t>
1> ]
1> No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called
如何将上面的代码正确转换为Unicode?
谢谢。
附言:
我正在运行Visual Studio 2012。