This commit is contained in:
2025-10-25 03:02:53 +03:00
commit 043225d523
3416 changed files with 681196 additions and 0 deletions

210
cppdraft/locale/numpunct.md Normal file
View File

@@ -0,0 +1,210 @@
[locale.numpunct]
# 28 Text processing library [[text]](./#text)
## 28.3 Localization library [[localization]](localization#locale.numpunct)
### 28.3.4 Standard locale categories [[locale.categories]](locale.categories#locale.numpunct)
#### 28.3.4.4 The numeric punctuation facet [[facet.numpunct]](facet.numpunct#locale.numpunct)
#### 28.3.4.4.1 Class template numpunct [locale.numpunct]
#### [28.3.4.4.1.1](#general) General [[locale.numpunct.general]](locale.numpunct.general)
[🔗](#lib:numpunct)
namespace std {template<class charT>class numpunct : public locale::facet {public:using char_type = charT; using string_type = basic_string<charT>; 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](#general-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L3137)
numpunct<> specifies numeric punctuation[.](#general-1.sentence-1)
The specializations
required in Table [91](locale.category#tab:locale.category.facets "Table 91: Locale category facets") ([[locale.category]](locale.category "28.3.3.1.2.1Type locale::category")),
namely numpunct<wchar_t> and numpunct<char>,
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[.](#general-1.sentence-2)
[2](#general-2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L3153)
The syntax for number formats is as follows,
where *digit* represents the radix set
specified by the fmtflags argument value, and*thousands-sep* and *decimal-point* are the results of corresponding numpunct<charT> members[.](#general-2.sentence-1)
Integer values have the format:
intval :
[*sign*](lex.fcon#nt:sign "5.13.4Floating-point literals[lex.fcon]")opt units
[*sign*](lex.fcon#nt:sign "5.13.4Floating-point literals[lex.fcon]") :
+
-
units :
digits
digits thousands-sep units
digits :
[*digit*](lex.name#nt:digit "5.11Identifiers[lex.name]") digitsopt
and floating-point values have:
floatval :
[*sign*](lex.fcon#nt:sign "5.13.4Floating-point literals[lex.fcon]")opt units fractionalopt exponentopt
[*sign*](lex.fcon#nt:sign "5.13.4Floating-point literals[lex.fcon]")opt decimal-point digits exponentopt
fractional :
decimal-point digitsopt
exponent :
e [*sign*](lex.fcon#nt:sign "5.13.4Floating-point literals[lex.fcon]")opt digits
e :
e
E
where the number of digits between *thousands-sep**s* is as specified by do_grouping()[.](#general-2.sentence-2)
For parsing,
if the *digits* portion contains no thousands-separators,
no grouping constraint is applied[.](#general-2.sentence-3)
#### [28.3.4.4.1.2](#facet.numpunct.members) Members [[facet.numpunct.members]](facet.numpunct.members)
[🔗](#lib:numpunct,decimal_point)
`char_type decimal_point() const;
`
[1](#facet.numpunct.members-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L3211)
*Returns*: do_decimal_point()[.](#facet.numpunct.members-1.sentence-1)
[🔗](#lib:numpunct,thousands_sep)
`char_type thousands_sep() const;
`
[2](#facet.numpunct.members-2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L3222)
*Returns*: do_thousands_sep()[.](#facet.numpunct.members-2.sentence-1)
[🔗](#lib:numpunct,grouping)
`string grouping() const;
`
[3](#facet.numpunct.members-3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L3233)
*Returns*: do_grouping()[.](#facet.numpunct.members-3.sentence-1)
[🔗](#lib:numpunct,truename)
`string_type truename() const;
string_type falsename() const;
`
[4](#facet.numpunct.members-4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L3246)
*Returns*: do_truename() ordo_falsename(),
respectively[.](#facet.numpunct.members-4.sentence-1)
#### [28.3.4.4.1.3](#facet.numpunct.virtuals) Virtual functions [[facet.numpunct.virtuals]](facet.numpunct.virtuals)
[🔗](#lib:numpunct,do_decimal_point)
`char_type do_decimal_point() const;
`
[1](#facet.numpunct.virtuals-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L3262)
*Returns*: A character for use as the decimal radix separator[.](#facet.numpunct.virtuals-1.sentence-1)
The required specializations return '.' or L'.'[.](#facet.numpunct.virtuals-1.sentence-2)
[🔗](#lib:numpunct,do_thousands_sep)
`char_type do_thousands_sep() const;
`
[2](#facet.numpunct.virtuals-2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L3274)
*Returns*: A character for use as the digit group separator[.](#facet.numpunct.virtuals-2.sentence-1)
The required specializations return ',' or L','[.](#facet.numpunct.virtuals-2.sentence-2)
[🔗](#lib:numpunct,do_grouping)
`string do_grouping() const;
`
[3](#facet.numpunct.virtuals-3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L3286)
*Returns*: A string vec used as a vector of integer values,
in which each element vec[i] represents the number of digits[225](#footnote-225 "Thus, the string &quot;\003&quot; specifies groups of 3 digits each, and &quot;3&quot; probably indicates groups of 51 (!) digits each, because 51 is the ASCII value of &quot;3&quot;.") in the group at position i,
starting with position 0 as the rightmost group[.](#facet.numpunct.virtuals-3.sentence-1)
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[.](#facet.numpunct.virtuals-3.sentence-2)
[4](#facet.numpunct.virtuals-4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L3303)
The required specializations return the empty string, indicating no grouping[.](#facet.numpunct.virtuals-4.sentence-1)
[🔗](#lib:numpunct,do_truename)
`string_type do_truename() const;
string_type do_falsename() const;
`
[5](#facet.numpunct.virtuals-5)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L3315)
*Returns*: A string representing the name of
the boolean value true or false, respectively[.](#facet.numpunct.virtuals-5.sentence-1)
[6](#facet.numpunct.virtuals-6)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L3320)
In the base class implementation
these names are "true" and "false",
or L"true" and L"false"[.](#facet.numpunct.virtuals-6.sentence-1)
[225)](#footnote-225)[225)](#footnoteref-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"[.](#footnote-225.sentence-1)