【问题标题】:stl codecvt errors c++stl codecvt错误c ++
【发布时间】:2014-06-14 14:29:08
【问题描述】:

我想使用 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 在那里被定义为模板,它有什么问题?请帮忙!

【问题讨论】:

  • 哪个词错了?您可以编辑您的问题并进行更正。

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


【解决方案1】:

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

std::wstring_convert<convert_typeX> converterX;

如果不是,你声明convert_typeX 是为了什么?

【讨论】:

  • 谢谢,这是我这边的错误,我把示例代码弄乱了一点。
猜你喜欢
  • 2012-01-13
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-09-29
  • 1970-01-01
  • 1970-01-01
  • 2013-04-30
  • 1970-01-01
相关资源
最近更新 更多