Share via


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

必要条件

ヘッダー: <locale>

名前空間: std