gpt4 book ai didi

c++ - STL codecvt 错误 c++

转载 作者:太空宇宙 更新时间:2023-11-04 11:32:26 30 4
gpt4 key购买 nike

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

最佳答案

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

std::wstring_convert<convert_typeX> converterX;

如果不是,您声明 convert_typeX 的目的是什么?

关于c++ - STL codecvt 错误 c++,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24220928/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com