std::money_put
提供: cppreference.com
<tbody>
</tbody>

| ヘッダ <locale> で定義
|
||
template< class CharT, class OutputIt = std::ostreambuf_iterator<CharT> > class money_put; |
||
クラス std::money_put は金額の値を文字列として書式化するためのルールをカプセル化します。 標準の入出力マニピュレータ std::put_money は入出力ストリームのロケールの std::money_put ファセットを使用します。
継承図
型の要件
-OutputIt は LegacyOutputIterator の要件を満たさなければなりません。
|
特殊化
2つのスタンドアロンな (ロケール非依存な) 完全特殊化および2つの部分特殊化が標準ライブラリによって提供されます。
ヘッダ
<locale> で定義 | |
std::money_put<char>
|
金額値のナロー文字列表現を作成します |
std::money_put<wchar_t>
|
金額値のワイド文字列表現を作成します |
std::money_put<char, OutputIt>
|
カスタム出力イテレータを用いて金額値のナロー文字列表現を作成します |
std::money_put<wchar_t, OutputIt>
|
カスタム出力イテレータを用いて金額値のワイド文字列表現を作成します |
さらに、 C++ のプログラム内で構築されたすべてのロケールオブジェクトは、これらの特殊化の独自の (ロケール固有の) バージョンを実装します。
メンバ型
| メンバ型 | 定義 |
char_type
|
CharT
|
string_type
|
std::basic_string<CharT>
|
iter_type
|
OutputIt
|
メンバ関数
| 新しい money_put ファセットを構築します (パブリックメンバ関数) | |
| money_put ファセットを破棄します (プロテクテッドメンバ関数) | |
invokes do_put (パブリックメンバ関数) |
プロテクテッドメンバ関数
[仮想] |
金額値を書式化して出力ストリームに書き込みます (仮想プロテクテッドメンバ関数) |
メンバオブジェクト
static std::locale::id id |
ロケールの id (パブリックメンバオブジェクト) |
例
Run this code
#include <iostream>
#include <locale>
#include <iomanip>
#include <iterator>
int main()
{
// using the IO manipulator
std::cout.imbue(std::locale("en_US.UTF-8"));
std::cout << "american locale: "
<< std::showbase << std::put_money(12345678.9)<< '\n';
// using the facet directly
std::cout.imbue(std::locale("de_DE.UTF-8"));
std::cout << "german locale: " ;
auto& f = std::use_facet<std::money_put<char>>(std::cout.getloc());
f.put({std::cout}, false, std::cout, std::cout.fill(), 12345678.9 );
std::cout << '\n';
}
出力:
american locale: $123,456.79
german locale: 123.456,79 €
関連項目
| std::money_get および std::money_put で使用される金額の書式パラメータを定義します (クラステンプレート) | |
| 入力文字シーケンスから金額の値をパースおよび構築します (クラステンプレート) | |
(C++11) |
金額をフォーマットして出力します (関数テンプレート) |