简体   繁体   English

stl codecvt错误C ++

[英]stl codecvt errors c++

i want to use the codecvt to convert the std:wstring to std::string like so 我想使用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;

I'am using vs2012, and i get the following compilation errors: 我正在使用vs2012,并且出现以下编译错误:

error C2825: '_Codecvt': must be a class or namespace when followed by '::'
error C2039: 'state_type' : is not a member of '`global namespace''

All this errors generates from the file xlocbuf on the line 所有这些错误都是从该行的文件xlocbuf生成的

typedef typename _Codecvt::state_type state_type;

_Codevct is defined there as template, what can be wrong with it? _Codevct在那里定义为模板,它可能有什么问题? Please help! 请帮忙!

The first template parameter of std::wstring_convert should be a codecvt class. std::wstring_convert的第一个模板参数应为codecvt类。 wchar_t is not such a class. wchar_t不是这样的类。 You likely want 你可能想要

std::wstring_convert<convert_typeX> converterX;

If not, what have you declared convert_typeX for? 如果没有,您声明了convert_typeX是什么?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM