std::use_facet
提供: cppreference.com
<tbody>
</tbody>
| ヘッダ <locale> で定義
|
||
template< class Facet > const Facet& use_facet( const std::locale& loc ); |
||
loc によって実装されるファセットへの参照を取得します。
引数
| loc | - | 問い合わせるロケールオブジェクト |
戻り値
ファセットへの参照を返します。 この関数によって返された参照は Facet を実装する任意の std::locale オブジェクトが存在している限り有効です。
例外
std::has_facet<Facet>(loc) == false の場合は std::bad_cast。
例
ユーザの好むロケールによって使用される3文字の国名を表示します。
Run this code
#include <iostream>
#include <locale>
int main()
{
std::locale loc = std::locale(""); // user's preferred locale
std::cout << "Your currency string is "
<< std::use_facet<std::moneypunct<char, true>>(loc).curr_symbol() << '\n';
}
出力:
Your currency string is USD
関連項目
| 文化の違いをカプセル化する多相的なファセットの集合 (クラス) | |
| ロケールが特定のファセットを実装しているかどうか調べます (関数テンプレート) |