我想使用codecvt将std:wstring转换为std :: string,如此
#include <ostream>
#include <sstream>
#include <locale>
#include <cstdlib>
#include <codecvt>
//some additional code
typedef std::codecvt_utf8<wchar_t> convert_typeX;
std::wstring_convert<wchar_t> converterX;
我正在使用vs2012,我收到以下编译错误:
error C2825: '_Codecvt': must be a class or namespace when followed by '::'
error C2039: 'state_type' : is not a member of '`global namespace''
所有这些错误都来自行
上的文件xlocbuftypedef typename _Codecvt::state_type state_type;
_Codevct被定义为模板,它可能有什么问题?请帮忙!
答案 0 :(得分:1)
std::wstring_convert
的第一个模板参数应该是codecvt
类。 wchar_t
不是这样的一个类。你可能想要
std::wstring_convert<convert_typeX> converterX;
如果没有,你宣布convert_typeX
为什么?