名前空間
変種
操作

std::numpunct_byname

From cppreference.com
< cpp‎ | locale
 
 
 
 
ヘッダー <locale> で定義
template< class CharT >
class numpunct_byname : public std::numpunct<CharT>;

std::numpunct_byname は、構築時に指定されたロケールの数値句読点の優先事項をカプセル化する、std::numpunct ファセットです。

目次

[編集] 特殊化

標準ライブラリは、以下の特殊化を提供することが保証されています。

ヘッダー <locale> で定義
std::numpunct_byname<char> ナロー文字 I/O 用のロケール固有の std::numpunct ファセット
std::numpunct_byname<wchar_t> ワイド文字 I/O 用のロケール固有の std::numpunct ファセット

[編集] ネストされた型

定義
char_type CharT
string_type std::basic_string<CharT>

[編集] メンバ関数

(コンストラクタ)
新しい numpunct_byname ファセットを構築します。
(public member function) [編集]
(デストラクタ)
numpunct_byname ファセットを破棄します。
(protected member function) [編集]

std::numpunct_byname::numpunct_byname

explicit numpunct_byname( const char* name, std::size_t refs = 0 );
explicit numpunct_byname( const std::string& name, std::size_t refs = 0 );
(C++11以降)

name で指定されたロケールの新しい std::numpunct_byname ファセットを構築します。

refs はリソース管理に使用されます。 refs == 0 の場合、それを持つ最後の std::locale オブジェクトが破棄されるときに、実装はファセットを破棄します。それ以外の場合、オブジェクトは破棄されません。

パラメータ

name - ロケールの名前
refs - ファセットを参照する参照の数

std::numpunct_byname::~numpunct_byname

protected:
~numpunct_byname();

ファセットを破棄します。

std::numpunct から継承

ネストされた型

定義
char_type CharT
string_type std::basic_string<CharT>

[編集] データメンバ

メンバ 説明
std::locale::id id [static] ファセットの識別子

メンバ関数

do_decimal_point を呼び出します。
(std::numpunct<CharT> の public メンバ関数) [編集]
do_thousands_sep を呼び出します。
(std::numpunct<CharT> の public メンバ関数) [編集]
do_grouping を呼び出します。
(std::numpunct<CharT> の public メンバ関数) [編集]
do_truename または do_falsename を呼び出します。
(std::numpunct<CharT> の public メンバ関数) [編集]

Protected member functions

小数点として使用する文字を提供します
(std::numpunct<CharT> の virtual protected メンバ関数) [編集]
千単位の区切り文字として使用する文字を提供します
(std::numpunct<CharT> の virtual protected メンバ関数) [編集]
[virtual]
各桁区切り記号のペア間の桁数を提供します。
(std::numpunct<CharT> の virtual protected メンバ関数) [編集]
ブール値 truefalse の名前として使用される文字列を提供します。
(std::numpunct<CharT> の virtual protected メンバ関数) [編集]

[編集]

この例では、ロケールの他の部分を変更せずに、別の言語の数値句読点の規則を適用する方法を示します。

#include <iostream>
#include <locale>
 
int main()
{
    const double number = 1000.25;
    std::wcout << L"default locale: " << number << L'\n';
    std::wcout.imbue(std::locale(std::wcout.getloc(),
                                 new std::numpunct_byname<wchar_t>("ru_RU.UTF8")));
    std::wcout << L"default locale with russian numpunct: " << number << L'\n';
}

出力

default locale: 1000.25
default locale with russian numpunct: 1 000,25

[編集] 関連項目

数値の句読点ルールを定義する
(クラステンプレート) [編集]
English 日本語 中文(简体) 中文(繁體)