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

std::has_facet

Defined in header <locale>

?

?

template< class Facet > bool has_facet( const locale& loc );

?

?

检查区域设置是否loc实现facetFacet...

参数

loc

-

the locale object to query

返回值

回报true如果小面Facet已安装在区域设置中。loc,,,false否则。

例外

(none)

(until C++11)

noexcept specification: noexcept

(since C++11)

二次

代码语言:javascript
复制
#include <iostream>
#include <locale>
 
// minimal custom facet
struct myfacet : public std::locale::facet {
    static std::locale::id id;
};
 
std::locale::id myfacet::id;
 
int main()
{
    // loc is a "C" locale with myfacet added
    std::locale loc(std::locale::classic(), new myfacet);
    std::cout << std::boolalpha
              << "Can loc classify chars? "
              << std::has_facet<std::ctype<char>>(loc) << '\n'
              << "Can loc classify char32_t? "
              << std::has_facet<std::ctype<char32_t>>(loc) << '\n'
              << "Does loc implement myfacet? "
              << std::has_facet<myfacet>(loc) << '\n';
}

二次

产出:

二次

代码语言:javascript
复制
Can loc classify chars? true
Can loc classify char32_t? false
Does loc implement myfacet? true

二次

另见

locale

set of polymorphic facets that encapsulate cultural differences (class)

use_facet

obtains a facet from a locale (function template)

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

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

扫码关注腾讯云开发者

领取腾讯云代金券

http://www.vxiaotou.com