gpt4 book ai didi

C++11:std::locale::empty() 是一个东西吗?

转载 作者:太空狗 更新时间:2023-10-29 21:35:40 27 4
gpt4 key购买 nike

正在尝试编译 some code来自 StackOverflow,基本上,这些行:

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' is not a member of 'std::locale'

我同意编译器,并检查了像 cppreference 这样的文档- 没有关于此类事情的信息。头文件也不显示任何内容。

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

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

最佳答案

这是语言环境类的特定于平台的扩展,它曾经在 this MSVC documentation 中描述过*:

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

static locale empty( );

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 文档链接现已过时,最佳替代品请参见 this documentation page相反

关于C++11:std::locale::empty() 是一个东西吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41753308/

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