Files
cppdraft_translate/cppdraft/locale/numpunct.md
2025-10-25 03:02:53 +03:00

7.2 KiB
Raw Blame History

[locale.numpunct]

28 Text processing library [text]

28.3 Localization library [localization]

28.3.4 Standard locale categories [locale.categories]

28.3.4.4 The numeric punctuation facet [facet.numpunct]

28.3.4.4.1 Class template numpunct [locale.numpunct]

28.3.4.4.1.1 General [locale.numpunct.general]

🔗

namespace std {templateclass numpunct : public locale::facet {public:using char_type = charT; using string_type = basic_string; explicit numpunct(size_t refs = 0);

char_type decimal_point() const; char_type thousands_sep() const; string grouping() const; string_type truename() const; string_type falsename() const; static locale::id id; protected:~numpunct(); // virtualvirtual char_type do_decimal_point() const; virtual char_type do_thousands_sep() const; virtual string do_grouping() const; virtual string_type do_truename() const; // for boolvirtual string_type do_falsename() const; // for bool};}

1

#

numpunct<> specifies numeric punctuation.

The specializations required in Table 91 ([locale.category]), namely numpunct<wchar_t> and numpunct, provide classic "C" numeric formats, i.e., they contain information equivalent to that contained in the "C" locale or their wide character counterparts as if obtained by a call to widen.

2

#

The syntax for number formats is as follows, where digit represents the radix set specified by the fmtflags argument value, andthousands-sep and decimal-point are the results of corresponding numpunct members.

Integer values have the format:

intval :
signopt units

sign :
+

units :
digits
digits thousands-sep units

digits :
digit digitsopt

and floating-point values have:

floatval :
signopt units fractionalopt exponentopt
signopt decimal-point digits exponentopt

fractional :
decimal-point digitsopt

exponent :
e signopt digits

e :
e
E

where the number of digits between thousands-sep**s is as specified by do_grouping().

For parsing, if the digits portion contains no thousands-separators, no grouping constraint is applied.

28.3.4.4.1.2 Members [facet.numpunct.members]

🔗

char_type decimal_point() const;

1

#

Returns: do_decimal_point().

🔗

char_type thousands_sep() const;

2

#

Returns: do_thousands_sep().

🔗

string grouping() const;

3

#

Returns: do_grouping().

🔗

string_type truename() const; string_type falsename() const;

4

#

Returns: do_truename() ordo_falsename(), respectively.

28.3.4.4.1.3 Virtual functions [facet.numpunct.virtuals]

🔗

char_type do_decimal_point() const;

1

#

Returns: A character for use as the decimal radix separator.

The required specializations return '.' or L'.'.

🔗

char_type do_thousands_sep() const;

2

#

Returns: A character for use as the digit group separator.

The required specializations return ',' or L','.

🔗

string do_grouping() const;

3

#

Returns: A string vec used as a vector of integer values, in which each element vec[i] represents the number of digits225 in the group at position i, starting with position 0 as the rightmost group.

If vec.size() <= i, the number is the same as group (i - 1); if (i < 0 || vec[i] <= 0 || vec[i] == CHAR_MAX), the size of the digit group is unlimited.

4

#

The required specializations return the empty string, indicating no grouping.

🔗

string_type do_truename() const; string_type do_falsename() const;

5

#

Returns: A string representing the name of the boolean value true or false, respectively.

6

#

In the base class implementation these names are "true" and "false", or L"true" and L"false".

225)225)

Thus, the string "\003" specifies groups of 3 digits each, and"3" probably indicates groups of 51 (!) digits each, because 51 is the ASCII value of "3".