[locale.money.get]

# 28 Text processing library [[text]](./#text)

## 28.3 Localization library [[localization]](localization#locale.money.get)

### 28.3.4 Standard locale categories [[locale.categories]](locale.categories#locale.money.get)

#### 28.3.4.7 The monetary category [[category.monetary]](category.monetary#locale.money.get)

#### 28.3.4.7.2 Class template money_get [locale.money.get]

#### [28.3.4.7.2.1](#general) General [[locale.money.get.general]](locale.money.get.general)

[ð](#lib:money_get)

namespace std {template<class charT, class InputIterator = istreambuf_iterator<charT>>class money_get : public locale::facet {public:using char_type = charT; using iter_type = InputIterator; using string_type = basic_string<charT>; explicit money_get(size_t refs = 0);

 iter_type get(iter_type s, iter_type end, bool intl,
 ios_base& f, ios_base::iostate& err, long double& units) const;
 iter_type get(iter_type s, iter_type end, bool intl,
 ios_base& f, ios_base::iostate& err,
 string_type& digits) const; static locale::id id; protected:~money_get(); virtual iter_type do_get(iter_type, iter_type, bool, ios_base&,
 ios_base::iostate& err, long double& units) const; virtual iter_type do_get(iter_type, iter_type, bool, ios_base&,
 ios_base::iostate& err, string_type& digits) const; };}

#### [28.3.4.7.2.2](#members) Members [[locale.money.get.members]](locale.money.get.members)

[ð](#lib:money_get,get)

`iter_type get(iter_type s, iter_type end, bool intl, ios_base& f,
              ios_base::iostate& err, long double& quant) const;
iter_type get(iter_type s, iter_type end, bool intl, ios_base& f,
              ios_base::iostate& err, string_type& quant) const;
`

[1](#members-1)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L4175)

*Returns*: do_get(s, end, intl, f, err, quant)[.](#members-1.sentence-1)

#### [28.3.4.7.2.3](#virtuals) Virtual functions [[locale.money.get.virtuals]](locale.money.get.virtuals)

[ð](#lib:money_get,do_get)

`iter_type do_get(iter_type s, iter_type end, bool intl, ios_base& str,
                 ios_base::iostate& err, long double& units) const;
iter_type do_get(iter_type s, iter_type end, bool intl, ios_base& str,
                 ios_base::iostate& err, string_type& digits) const;
`

[1](#virtuals-1)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L4191)

*Effects*: Reads characters from s to parse and construct a monetary value
according to the format specified by
a moneypunct<charT, Intl> facet reference mp and the character mapping specified by
a ctype<charT> facet reference ct obtained from the locale returned by str.getloc(), andstr.flags()[.](#virtuals-1.sentence-1)

If a valid sequence is recognized, does not change err;
otherwise, sets err to (err | str.failbit), or(err | str.failbit | str.eofbit) if no more characters are available,
and does not change units or digits[.](#virtuals-1.sentence-2)

Uses the pattern returned by mp.neg_format() to parse all values[.](#virtuals-1.sentence-3)

The result is returned as an integral value stored in units or as a sequence of digits possibly preceded by a minus sign
(as produced by ct.widen(c) where c is '-' or
in the range from '0' through '9' (inclusive))
stored in digits[.](#virtuals-1.sentence-4)

[*Example [1](#virtuals-example-1)*:

The sequence $1,056.23 in a common United States locale would yield,
for units, 105623, or,
for digits, "105623"[.](#virtuals-1.sentence-5)

â *end example*]

If mp.grouping() indicates that no thousands separators are permitted,
any such characters are not read, and
parsing is terminated at the point where they first appear[.](#virtuals-1.sentence-6)

Otherwise, thousands separators are optional;
if present, they are checked for correct placement only after
all format components have been read[.](#virtuals-1.sentence-7)

[2](#virtuals-2)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L4223)

Where money_base​::​space or money_base​::​none appears as the last element in the format pattern,
no whitespace is consumed[.](#virtuals-2.sentence-1)

Otherwise, where money_base​::​space appears in any of
the initial elements of the format pattern,
at least one whitespace character is required[.](#virtuals-2.sentence-2)

Where money_base​::​none appears
in any of the initial elements of the format pattern,
whitespace is allowed but not required[.](#virtuals-2.sentence-3)

If (str.flags() & str.showbase) is false,
the currency symbol is optional and
is consumed only if other characters are needed to complete the format;
otherwise, the currency symbol is required[.](#virtuals-2.sentence-4)

[3](#virtuals-3)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L4238)

If the first character (if any) in
the string pos returned by mp.positive_sign() or
the string neg returned by mp.negative_sign() is recognized in the position indicated by sign in the format pattern,
it is consumed and
any remaining characters in the string are required
after all the other format components[.](#virtuals-3.sentence-1)

[*Example [2](#virtuals-example-2)*:

If showbase is off,
then for a neg value of "()" and
a currency symbol of "L",
in "(100 L)" the "L" is consumed;
but if neg is "-",
the "L" in "-100 L" is not consumed[.](#virtuals-3.sentence-2)

â *end example*]

If pos or neg is empty,
the sign component is optional, and
if no sign is detected,
the result is given the sign that corresponds to the source of the empty string[.](#virtuals-3.sentence-3)

Otherwise,
the character in the indicated position must match
the first character of pos or neg,
and the result is given the corresponding sign[.](#virtuals-3.sentence-4)

If the first character of pos is equal to
the first character of neg,
or if both strings are empty,
the result is given a positive sign[.](#virtuals-3.sentence-5)

[4](#virtuals-4)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L4267)

Digits in the numeric monetary component are extracted and
placed in digits, or into a character buffer buf1 for conversion to produce a value for units,
in the order in which they appear,
preceded by a minus sign if and only if the result is negative[.](#virtuals-4.sentence-1)

The value units is produced as if by[229](#footnote-229 "The semantics here are different from ct.narrow.")for (int i = 0; i < n; ++i) buf2[i] = src[find(atoms, atoms + sizeof(src), buf1[i]) - atoms];
buf2[n] = 0;
sscanf(buf2, "%Lf", &units); where n is the number of characters placed in buf1,buf2 is a character buffer, and
the values src and atoms are defined as if bystatic const char src[] = "0123456789-";
charT atoms[sizeof(src)];
ct.widen(src, src + sizeof(src) - 1, atoms);

[5](#virtuals-5)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L4292)

*Returns*: An iterator pointing immediately beyond
the last character recognized as part of a valid monetary quantity[.](#virtuals-5.sentence-1)

[229)](#footnote-229)[229)](#footnoteref-229)

The semantics here are different from ct.narrow[.](#footnote-229.sentence-1)
