use_facet

在区域设置返回到中存储的一个指定类型的引用。

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;
}
  

要求

页眉: <区域设置>

命名空间: std