use_facet

傳回在地區設定中指定之型別的 Facet 的參考。

template<class Facet>
   const Facet& use_facet(
      const locale& _Loc
   );

參數

  • _Loc
    包含 Facet 的型別 const 地區設定參考。

傳回值

在引數地區設定中所包含的類別 Facet Facet 的參考。

備註

,只要包含的地區設定的所有複本存在,然後 Facet 的參考是由樣板函式傳回保持有效。如果類別 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