首页
学习
活动
专区
工具
TVP
发布
精选内容/技术社群/优惠产品,尽在小程序
立即前往

std::locale::id

Defined in header <locale>

?

?

class locale::id;

?

?

全班std::locale::id提供特定于实现的区域设置方面的标识。派生的每个类std::locale::facet必须有一个公共静态成员名为id类型std::locale::id每一个std::locale对象维护其实现的方面的列表,并按其idS.

具有相同的方面id属于同一方面类别,并在添加到区域设置对象时相互替换。

成员函数

(constructor)

constructs a new id (public member function)

operator=

copy assignment operator is deleted (public member function)

下面的示例演示如何构造最小自定义方面。

二次

代码语言:javascript
复制
#include <iostream>
#include <locale>
 
struct myfacet : std::locale::facet
{
    myfacet(std::size_t refs = 0) : facet(refs) {}
    static std::locale::id id;
};
 
std::locale::id myfacet::id;
 
int main()
{
    std::locale myloc(std::locale(), new myfacet);
    std::cout << "has_facet<myfacet>(myloc) returns " << std::boolalpha
              << std::has_facet<myfacet>(myloc) << '\n';
}

二次

产出:

二次

代码语言:javascript
复制
has_facet<myfacet>(myloc) returns true

二次

另见

facet

the base class for all facet categories: each facet of any category is derived from this type (class)

代码语言:txt
复制
 ? cppreference.com

在CreativeCommonsAttribution下授权-ShareAlike未移植许可v3.0。

扫码关注腾讯云开发者

领取腾讯云代金券

http://www.vxiaotou.com