std::locale::id
提供: cppreference.com
<tbody>
</tbody>
| ヘッダ <locale> で定義
|
||
class locale::id; |
||
クラス std::locale::id はロケールのファセットの処理系固有の識別を提供します。 std::locale::facet から派生するそれぞれのクラスは std::locale::id 型の id という名前のパブリック静的メンバを持たなければならず、それぞれの std::locale オブジェクトは、実装するファセットの一覧を、その id でインデックス付けして、管理します。
同じ id を持つファセットは、同じファセットカテゴリに所属し、ロケールオブジェクトに追加されたとき、お互いを置き換えます。
メンバ関数
| 新しい id を構築します (パブリックメンバ関数) | |
operator= |
コピー代入演算子は削除されています (パブリックメンバ関数) |
例
以下の例は最小限のカスタムファセットの構築方法を示します。
Run this code
#include <iostream>
#include <locale>
struct myfacet : std::locale::facet
{
myfacet(std::size_t refs = 0) : facet(refs) {}
static std::locale::id id;
};
std::locale::id myfacet::id;
int main()
{
std::locale myloc(std::locale(), new myfacet);
std::cout << "has_facet<myfacet>(myloc) returns " << std::boolalpha
<< std::has_facet<myfacet>(myloc) << '\n';
}
出力:
has_facet<myfacet>(myloc) returns true
関連項目
| すべてのファセットカテゴリのための基底クラス。 任意のカテゴリの各ファセットはこの型から派生します (クラス) |