stl codecvt errors c ++

时间:2014-06-14 14:29:09

标签: c++ visual-studio-2012 c++11 stl codecvt

我想使用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''

所有这些错误都来自行

上的文件xlocbuf
typedef typename _Codecvt::state_type state_type;

_Codevct被定义为模板,它可能有什么问题?请帮忙!

1 个答案:

答案 0 :(得分:1)

std::wstring_convert的第一个模板参数应该是codecvt类。 wchar_t不是这样的一个类。你可能想要

std::wstring_convert<convert_typeX> converterX;

如果没有,你宣布convert_typeX为什么?