共用方式為


use_facet

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

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

參數

  • _Loc
    包含這個型別常數地區設定參考。

傳回值

對類別 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;
}
  

需求

標題: <地區設定>

命名空間: std