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

| ヘッダ <locale> で定義
|
||
template< class CharT, class InputIt = std::istreambuf_iterator<CharT> > class money_get; |
||
クラステンプレート std::money_get は文字ストリームから金額の値を解析するためのルールをカプセル化します。 標準の入出力マニピュレータ std::get_money は入出力ストリームのロケールの std::money_get ファセットを使用します。
継承図
型の要件
-InputIt は LegacyInputIterator の要件を満たさなければなりません。
|
特殊化
2つのスタンドアロンな (ロケール非依存な) 完全特殊化および2つの部分特殊化が標準ライブラリによって提供されます。
ヘッダ
<locale> で定義 | |
std::money_get<char>
|
金額値のナロー文字列表現を解析します |
std::money_get<wchar_t>
|
金額値のワイド文字列表現を解析します |
std::money_get<char, InputIt>
|
カスタム入力イテレータを用いて金額値のナロー文字列表現を解析します |
std::money_get<wchar_t, InputIt>
|
カスタム入力イテレータを用いて金額値のワイド文字列表現を解析します |
さらに、 C++ のプログラム内で構築されたすべてのロケールオブジェクトは、これらの特殊化の独自の (ロケール固有の) バージョンを実装します。
メンバ型
| メンバ型 | 定義 |
char_type
|
CharT
|
string_type
|
std::basic_string<CharT>
|
iter_type
|
InputIt
|
メンバ関数
| 新しい money_get ファセットを構築します (パブリックメンバ関数) | |
| money_get ファセットを破棄します (プロテクテッドメンバ関数) | |
do_get を呼びます (パブリックメンバ関数) |
プロテクテッドメンバ関数
[仮想] |
入力ストリームから金額値を解析します (仮想プロテクテッドメンバ関数) |
メンバオブジェクト
static std::locale::id id |
ロケールの id (パブリックメンバオブジェクト) |
例
Run this code
#include <iostream>
#include <sstream>
#include <locale>
#include <iomanip>
#include <iterator>
int main()
{
std::string str = "$1.11 $2.22 $3.33";
std::cout << std::fixed << std::setprecision(2);
std::cout << '"' << str << "\" parsed with the I/O manipulator: ";
std::istringstream s1(str);
s1.imbue(std::locale("en_US.UTF-8"));
long double val;
while(s1 >> std::get_money(val))
std::cout << val/100 << ' ';
std::cout << '\n';
str = "USD 1,234.56";
std::cout << '"' << str << "\" parsed with the facet directly: ";
std::istringstream s2(str);
s2.imbue(std::locale("en_US.UTF-8"));
auto& f = std::use_facet<std::money_get<char>>(s2.getloc());
std::ios_base::iostate err;
std::istreambuf_iterator<char> beg(s2), end;
f.get(beg, end, true, s2, err, val);
std::cout << val/100 << '\n';
}
出力:
"$1.11 $2.22 $3.33" parsed with the I/O manipulator: 1.11 2.22 3.33
"USD 1,234.56" parsed with the facet directly: 1234.56
関連項目
| std::money_get および std::money_put で使用される金額の書式パラメータを定義します (クラステンプレート) | |
| 文字シーケンスとして出力するために金額の値をフォーマットします (クラステンプレート) | |
(C++11) |
金額をパースします (関数テンプレート) |