返回对区域设置存储的特定类型的方面。
template<class Facet>
const Facet& use_facet(
const locale& _Loc
);
参数
- _Loc
包含方面的类型常量区域设置引用。
返回值
对参数区域设置中包含的选件类 Facet 方面的引用。
备注
只要包含的区域设置的所有副本存在,则个方面的引用由模板函数返回保持有效。如果选件类 Facet 这方面对象不会在参数区域设置的列表,函数引发 bad_cast 异常。
示例
// locale_use_facet.cpp
// compile with: /EHsc
#include <locale>
#include <iostream>
using namespace std;
int main( )
{
locale loc1 ( "German_Germany" ), loc2 ( "English_Australia" );
bool result1 = use_facet<ctype<char> > ( loc1 ).is(
ctype_base::alpha, 'a'
);
bool result2 = use_facet<ctype<char> > ( loc2 ).is( ctype_base::alpha, '!'
);
if ( result1 )
cout << "The character 'a' in locale loc1 is alphabetic."
<< endl;
else
cout << "The character 'a' in locale loc1 is not alphabetic."
<< endl;
if ( result2 )
cout << "The character '!' in locale loc2 is alphabetic."
<< endl;
else
cout << "The character '!' in locale loc2 is not alphabetic."
<< endl;
}
要求
标头: <locale>
命名空间: std