C ++ 11:std :: locale :: empty()甚至是东西吗? [英] C++11: is std::locale::empty() even a thing?

查看:57
本文介绍了C ++ 11:std :: locale :: empty()甚至是东西吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

尝试从StackOverflow编译一些代码,基本上,这些行:

Trying to compile some code from StackOverflow, basically, these lines:

std::wifstream wif(filename);
wif.imbue(std::locale(std::locale::empty(), new std::codecvt_utf8<wchar_t>));

GCC版本: gcc(Ubuntu 5.4.0-6ubuntu1〜16.04.4)5.4.0

我收到一个编译错误:

'empty'不是'std :: locale'的成员

'empty' is not a member of 'std::locale'

我同意编译器,并使用 cppreference 等文档进行了检查-没有关于这件事的信息.头文件也不会显示任何内容.

And I agree with the compiler, checked with documentation like cppreference - there is no info about such thing. Header files as well do not show anything.

我想知道这是我还是其他主题的示例代码...

I wonder, if this is just me or the sample code from another topic...

可以是MSVC功能吗?(我使用的示例代码来自与Windows有关的问题)

Can it be a MSVC feature? (the sample code I used is from the question related to Windows)

推荐答案

这是语言环境类的特定于平台的扩展,它以前在

This is a platform-specific extension to the locale class, and it used to be described in this MSVC documentation*:

在此实现中,您还可以调用静态成员函数:

In this implementation, you can also call the static member function:

static locale empty( );

构造一个没有构面的 locale 对象.这也是一个透明的语言环境;如果模板函数 has_facet use_facet 在透明语言环境中找不到请求的构面,则它们将首先查询全局语言环境,然后,如果是透明的,则查询经典语言环境./p>

to construct a locale object that has no facets. It is also a transparent locale; if the template functions has_facet and use_facet cannot find the requested facet in a transparent locale, they consult first the global locale and then, if that is transparent, the classic locale.

* MSVC文档链接现在已过时,要获得最佳替换,请参见

* the MSVC documentation link is outdated now, for best replacement see this documentation page instead

这篇关于C ++ 11:std :: locale :: empty()甚至是东西吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆