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

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,47 @@
[locale.categories.general]
# 28 Text processing library [[text]](./#text)
## 28.3 Localization library [[localization]](localization#locale.categories.general)
### 28.3.4 Standard locale categories [[locale.categories]](locale.categories#general)
#### 28.3.4.1 General [locale.categories.general]
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L1282)
Each of the standard categories includes a family of facets[.](#1.sentence-1)
Some of these implement formatting or parsing of a datum,
for use by standard or users' iostream operators << and >>,
as members put() and get(), respectively[.](#1.sentence-2)
Each such member function takes anios_base& argument whose membersflags(),precision(),
andwidth(),
specify the format of the corresponding datum ([[ios.base]](ios.base "31.5.2Class ios_­base"))[.](#1.sentence-3)
Those functions which need to use other facets call its member getloc() to retrieve the locale imbued there[.](#1.sentence-4)
Formatting facets use the character argument fill to fill out the specified width where necessary[.](#1.sentence-5)
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L1303)
The put() members make no provision for error reporting[.](#2.sentence-1)
(Any failures of the OutputIterator argument can be extracted from
the returned iterator[.](#2.sentence-2))
The get() members take an ios_base::iostate& argument
whose value they ignore,
but set to ios_base::failbit in case of a parse error[.](#2.sentence-3)
[3](#3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L1311)
Within [[locale.categories]](locale.categories "28.3.4Standard locale categories") it is unspecified whether
one virtual function calls another virtual function[.](#3.sentence-1)

137
cppdraft/locale/category.md Normal file
View File

@@ -0,0 +1,137 @@
[locale.category]
# 28 Text processing library [[text]](./#text)
## 28.3 Localization library [[localization]](localization#locale.category)
### 28.3.3 Locales [[locales]](locales#locale.category)
#### 28.3.3.1 Class locale [[locale]](locale#category)
#### 28.3.3.1.2 Types [[locale.types]](locale.types#locale.category)
#### 28.3.3.1.2.1 Type locale::category [locale.category]
[🔗](#lib:locale,category)
`using category = int;
`
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L633)
*Valid* category values
include the locale member bitmask elementscollate,ctype,monetary,numeric,time,
andmessages,
each of which represents a single locale category[.](#1.sentence-1)
In addition, locale member bitmask constant none is defined as zero and represents no category[.](#1.sentence-2)
And locale member bitmask constant all is defined such that the expression(collate | ctype | monetary | numeric | time | messages | all) == all is true,
and represents the union of all categories[.](#1.sentence-3)
Further, the expression (X | Y),
where X and Y each represent a single category,
represents the union of the two categories[.](#1.sentence-4)
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L657)
locale member functions
expecting a category argument
require one of the category values defined above, or
the union of two or more such values[.](#2.sentence-1)
Such a category value identifies a set of locale categories[.](#2.sentence-2)
Each locale category, in turn, identifies a set of locale facets,
including at least those shown in Table [91](#tab:locale.category.facets "Table 91: Locale category facets")[.](#2.sentence-3)
Table [91](#tab:locale.category.facets) — Locale category facets [[tab:locale.category.facets]](./tab:locale.category.facets)
| [🔗](#tab:locale.category.facets-row-1)<br>**Category** | **Includes facets** |
| --- | --- |
| [🔗](#tab:locale.category.facets-row-2)<br>collate | collate<char>, collate<wchar_t> |
| [🔗](#tab:locale.category.facets-row-3)<br>ctype | ctype<char>, ctype<wchar_t> |
| [🔗](#tab:locale.category.facets-row-4) | codecvt<char, char, mbstate_t> |
| [🔗](#tab:locale.category.facets-row-5) | codecvt<wchar_t, char, mbstate_t> |
| [🔗](#tab:locale.category.facets-row-6)<br>monetary | moneypunct<char>, moneypunct<wchar_t> |
| [🔗](#tab:locale.category.facets-row-7) | moneypunct<char, true>, moneypunct<wchar_t, true> |
| [🔗](#tab:locale.category.facets-row-8) | money_get<char>, money_get<wchar_t> |
| [🔗](#tab:locale.category.facets-row-9) | money_put<char>, money_put<wchar_t> |
| [🔗](#tab:locale.category.facets-row-10)<br>numeric | numpunct<char>, numpunct<wchar_t> |
| [🔗](#tab:locale.category.facets-row-11) | num_get<char>, num_get<wchar_t> |
| [🔗](#tab:locale.category.facets-row-12) | num_put<char>, num_put<wchar_t> |
| [🔗](#tab:locale.category.facets-row-13)<br>time | time_get<char>, time_get<wchar_t> |
| [🔗](#tab:locale.category.facets-row-14) | time_put<char>, time_put<wchar_t> |
| [🔗](#tab:locale.category.facets-row-15)<br>messages | messages<char>, messages<wchar_t> |
[3](#3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L686)
For any locale loc either constructed, or returned by locale::classic(),
and any facet Facet shown in Table [91](#tab:locale.category.facets "Table 91: Locale category facets"),has_facet<Facet>(loc) is true[.](#3.sentence-1)
Each locale member function
which takes a locale::category argument
operates on the corresponding set of facets[.](#3.sentence-2)
[4](#4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L695)
An implementation is required to provide those specializations
for facet templates identified as members of a category, and
for those shown in Table [92](#tab:locale.spec "Table 92: Required specializations")[.](#4.sentence-1)
Table [92](#tab:locale.spec) — Required specializations [[tab:locale.spec]](./tab:locale.spec)
| [🔗](#tab:locale.spec-row-1)<br>**Category** | **Includes facets** |
| --- | --- |
| [🔗](#tab:locale.spec-row-2)<br>collate | collate_byname<char>, collate_byname<wchar_t> |
| [🔗](#tab:locale.spec-row-3)<br>ctype | ctype_byname<char>, ctype_byname<wchar_t> |
| [🔗](#tab:locale.spec-row-4) | codecvt_byname<char, char, mbstate_t> |
| [🔗](#tab:locale.spec-row-5) | codecvt_byname<wchar_t, char, mbstate_t> |
| [🔗](#tab:locale.spec-row-6)<br>monetary | moneypunct_byname<char, International> |
| [🔗](#tab:locale.spec-row-7) | moneypunct_byname<wchar_t, International> |
| [🔗](#tab:locale.spec-row-8) | money_get<C, InputIterator> |
| [🔗](#tab:locale.spec-row-9) | money_put<C, OutputIterator> |
| [🔗](#tab:locale.spec-row-10)<br>numeric | numpunct_byname<char>, numpunct_byname<wchar_t> |
| [🔗](#tab:locale.spec-row-11) | num_get<C, InputIterator>, num_put<C, OutputIterator> |
| [🔗](#tab:locale.spec-row-12)<br>time | time_get<char, InputIterator> |
| [🔗](#tab:locale.spec-row-13) | time_get_byname<char, InputIterator> |
| [🔗](#tab:locale.spec-row-14) | time_get<wchar_t, InputIterator> |
| [🔗](#tab:locale.spec-row-15) | time_get_byname<wchar_t, InputIterator> |
| [🔗](#tab:locale.spec-row-16) | time_put<char, OutputIterator> |
| [🔗](#tab:locale.spec-row-17) | time_put_byname<char, OutputIterator> |
| [🔗](#tab:locale.spec-row-18) | time_put<wchar_t, OutputIterator> |
| [🔗](#tab:locale.spec-row-19) | time_put_byname<wchar_t, OutputIterator> |
| [🔗](#tab:locale.spec-row-20)<br>messages | messages_byname<char>, messages_byname<wchar_t> |
[5](#5)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L726)
The provided implementation of members of
facets num_get<charT> and num_put<charT> calls use_facet<F>(l) only for facet F of
types numpunct<charT> and ctype<charT>,
and for locale l the value obtained by calling member getloc() on the ios_base& argument to these functions[.](#5.sentence-1)
[6](#6)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L734)
In declarations of facets,
a template parameter with name InputIterator or OutputIterator indicates the set of all possible specializations on parameters that meet the*Cpp17InputIterator* requirements or*Cpp17OutputIterator* requirements,
respectively ([[iterator.requirements]](iterator.requirements "24.3Iterator requirements"))[.](#6.sentence-1)
A template parameter with name C represents
the set of types containing char, wchar_t, and any otherimplementation-defined
character container types ([[defns.character.container]](defns.character.container "3.10character container type"))
that meet the requirements for a character
on which any of the iostream components can be instantiated[.](#6.sentence-2)
A template parameter with name International represents the set of all possible specializations on a bool parameter[.](#6.sentence-3)

388
cppdraft/locale/codecvt.md Normal file
View File

@@ -0,0 +1,388 @@
[locale.codecvt]
# 28 Text processing library [[text]](./#text)
## 28.3 Localization library [[localization]](localization#locale.codecvt)
### 28.3.4 Standard locale categories [[locale.categories]](locale.categories#locale.codecvt)
#### 28.3.4.2 The ctype category [[category.ctype]](category.ctype#locale.codecvt)
#### 28.3.4.2.5 Class template codecvt [locale.codecvt]
#### [28.3.4.2.5.1](#general) General [[locale.codecvt.general]](locale.codecvt.general)
[🔗](#lib:codecvt)
namespace std {class codecvt_base {public:enum result { ok, partial, error, noconv }; }; template<class internT, class externT, class stateT>class codecvt : public locale::facet, public codecvt_base {public:using intern_type = internT; using extern_type = externT; using state_type = stateT; explicit codecvt(size_t refs = 0);
result out( stateT& state, const internT* from, const internT* from_end, const internT*& from_next,
externT* to, externT* to_end, externT*& to_next) const;
result unshift( stateT& state,
externT* to, externT* to_end, externT*& to_next) const;
result in( stateT& state, const externT* from, const externT* from_end, const externT*& from_next,
internT* to, internT* to_end, internT*& to_next) const; int encoding() const noexcept; bool always_noconv() const noexcept; int length(stateT&, const externT* from, const externT* end, size_t max) const; int max_length() const noexcept; static locale::id id; protected:~codecvt(); virtual result do_out( stateT& state, const internT* from, const internT* from_end, const internT*& from_next,
externT* to, externT* to_end, externT*& to_next) const; virtual result do_in( stateT& state, const externT* from, const externT* from_end, const externT*& from_next,
internT* to, internT* to_end, internT*& to_next) const; virtual result do_unshift( stateT& state,
externT* to, externT* to_end, externT*& to_next) const; virtual int do_encoding() const noexcept; virtual bool do_always_noconv() const noexcept; virtual int do_length(stateT&, const externT* from, const externT* end, size_t max) const; virtual int do_max_length() const noexcept; };}
[1](#general-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L2017)
The class codecvt<internT, externT, stateT> is for use
when converting from one character encoding to another,
such as from wide characters to multibyte characters or
between wide character encodings such as UTF-32 and EUC[.](#general-1.sentence-1)
[2](#general-2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L2023)
The stateT argument selects
the pair of character encodings being mapped between[.](#general-2.sentence-1)
[3](#general-3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L2027)
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"))
convert the implementation-defined native character set[.](#general-3.sentence-1)
codecvt<char, char, mbstate_t> implements a degenerate conversion;
it does not convert at all[.](#general-3.sentence-2)
codecvt<wchar_t, char, mbstate_t> converts between the native character sets for ordinary and wide characters[.](#general-3.sentence-3)
Specializations on mbstate_t perform conversion between encodings known to the library implementer[.](#general-3.sentence-4)
Other encodings can be converted by specializing on
a program-defined stateT type[.](#general-3.sentence-5)
Objects of type stateT can contain any state
that is useful to communicate to or from
the specialized do_in or do_out members[.](#general-3.sentence-6)
#### [28.3.4.2.5.2](#members) Members [[locale.codecvt.members]](locale.codecvt.members)
[🔗](#lib:codecvt,out)
`result out(
stateT& state,
const internT* from, const internT* from_end, const internT*& from_next,
externT* to, externT* to_end, externT*& to_next) const;
`
[1](#members-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L2054)
*Returns*: do_out(state, from, from_end, from_next, to, to_end, to_next)[.](#members-1.sentence-1)
[🔗](#lib:codecvt,unshift)
`result unshift(stateT& state, externT* to, externT* to_end, externT*& to_next) const;
`
[2](#members-2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L2065)
*Returns*: do_unshift(state, to, to_end, to_next)[.](#members-2.sentence-1)
[🔗](#lib:codecvt,in)
`result in(
stateT& state,
const externT* from, const externT* from_end, const externT*& from_next,
internT* to, internT* to_end, internT*& to_next) const;
`
[3](#members-3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L2079)
*Returns*: do_in(state, from, from_end, from_next, to, to_end, to_next)[.](#members-3.sentence-1)
[🔗](#lib:codecvt,encoding)
`int encoding() const noexcept;
`
[4](#members-4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L2090)
*Returns*: do_encoding()[.](#members-4.sentence-1)
[🔗](#lib:codecvt,always_noconv)
`bool always_noconv() const noexcept;
`
[5](#members-5)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L2101)
*Returns*: do_always_noconv()[.](#members-5.sentence-1)
[🔗](#lib:codecvt,length)
`int length(stateT& state, const externT* from, const externT* from_end, size_t max) const;
`
[6](#members-6)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L2112)
*Returns*: do_length(state, from, from_end, max)[.](#members-6.sentence-1)
[🔗](#lib:codecvt,max_length)
`int max_length() const noexcept;
`
[7](#members-7)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L2123)
*Returns*: do_max_length()[.](#members-7.sentence-1)
#### [28.3.4.2.5.3](#virtuals) Virtual functions [[locale.codecvt.virtuals]](locale.codecvt.virtuals)
[🔗](#lib:codecvt,do_out)
`result do_out(
stateT& state,
const internT* from, const internT* from_end, const internT*& from_next,
externT* to, externT* to_end, externT*& to_next) const;
result do_in(
stateT& state,
const externT* from, const externT* from_end, const externT*& from_next,
internT* to, internT* to_end, internT*& to_next) const;
`
[1](#virtuals-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L2145)
*Preconditions*: (from <= from_end && to <= to_end) is well-defined and true;state is initialized, if at the beginning of a sequence,
or else is equal to the result of converting
the preceding characters in the sequence[.](#virtuals-1.sentence-1)
[2](#virtuals-2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L2152)
*Effects*: Translates characters in the source range [from, from_end),
placing the results in sequential positions starting at destination to[.](#virtuals-2.sentence-1)
Converts no more than (from_end - from) source elements, and
stores no more than (to_end - to) destination elements[.](#virtuals-2.sentence-2)
[3](#virtuals-3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L2159)
Stops if it encounters a character it cannot convert[.](#virtuals-3.sentence-1)
It always leaves the from_next and to_next pointers
pointing one beyond the last element successfully converted[.](#virtuals-3.sentence-2)
If it returns noconv,internT and externT are the same type, and
the converted sequence is identical to
the input sequence [from, from_next),to_next is set equal to to,
the value of state is unchanged, and
there are no changes to the values in [to, to_end)[.](#virtuals-3.sentence-3)
[4](#virtuals-4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L2171)
A codecvt facet
that is used by basic_filebuf ([[file.streams]](file.streams "31.10File-based streams"))
shall have the property that ifdo_out(state, from, from_end, from_next, to, to_end, to_next) would return ok,
where from != from_end,
thendo_out(state, from, from + 1, from_next, to, to_end, to_next) shall also return ok,
and that ifdo_in(state, from, from_end, from_next, to, to_end, to_next) would return ok,
where to != to_end,
thendo_in(state, from, from_end, from_next, to, to + 1, to_next) shall also return ok[.](#virtuals-4.sentence-1)[220](#footnote-220 "Informally, this means that basic_­filebuf assumes that the mappings from internal to external characters is 1 to N: that a codecvt facet that is used by basic_­filebuf can translate characters one internal character at a time.")
[*Note [1](#virtuals-note-1)*:
As a result of operations on state,
it can return ok or partial and
set from_next == from and to_next != to[.](#virtuals-4.sentence-2)
— *end note*]
[5](#virtuals-5)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L2208)
*Returns*: An enumeration value, as summarized in Table [93](#tab:locale.codecvt.inout "Table 93: do_­in/do_­out result values")[.](#virtuals-5.sentence-1)
Table [93](#tab:locale.codecvt.inout) — do_in/do_out result values [[tab:locale.codecvt.inout]](./tab:locale.codecvt.inout)
| [🔗](#tab:locale.codecvt.inout-row-1)<br>**Value** | **Meaning** |
| --- | --- |
| [🔗](#tab:locale.codecvt.inout-row-2)<br>ok | completed the conversion |
| [🔗](#tab:locale.codecvt.inout-row-3)<br>partial | not all source characters converted |
| [🔗](#tab:locale.codecvt.inout-row-4)<br>error | encountered a character in [from, from_end) that cannot be converted |
| [🔗](#tab:locale.codecvt.inout-row-5)<br>noconv | internT and externT are the same type, and input sequence is identical to converted sequence |
A return value of partial,
if (from_next == from_end),
indicates
that either the destination sequence has not absorbed
all the available destination elements, or
that additional source elements are needed
before another destination element can be produced[.](#virtuals-5.sentence-2)
[6](#virtuals-6)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L2234)
*Remarks*: Its operations on state are unspecified[.](#virtuals-6.sentence-1)
[*Note [2](#virtuals-note-2)*:
This argument can be used, for example,
to maintain shift state,
to specify conversion options (such as count only), or
to identify a cache of seek offsets[.](#virtuals-6.sentence-2)
— *end note*]
[🔗](#lib:codecvt,do_unshift)
`result do_unshift(stateT& state, externT* to, externT* to_end, externT*& to_next) const;
`
[7](#virtuals-7)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L2251)
*Preconditions*: (to <= to_end) is well-defined and true;state is initialized, if at the beginning of a sequence,
or else is equal to the result of converting
the preceding characters in the sequence[.](#virtuals-7.sentence-1)
[8](#virtuals-8)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L2258)
*Effects*: Places characters starting at to that should be appended to terminate a sequence
when the current stateT is given by state[.](#virtuals-8.sentence-1)[221](#footnote-221 "Typically these will be characters to return the state to stateT().")
Stores no more than (to_end - to) destination elements, and
leaves the to_next pointer
pointing one beyond the last element successfully stored[.](#virtuals-8.sentence-2)
[9](#virtuals-9)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L2270)
*Returns*: An enumeration value, as summarized in Table [94](#tab:locale.codecvt.unshift "Table 94: do_­unshift result values")[.](#virtuals-9.sentence-1)
Table [94](#tab:locale.codecvt.unshift) — do_unshift result values [[tab:locale.codecvt.unshift]](./tab:locale.codecvt.unshift)
| [🔗](#tab:locale.codecvt.unshift-row-1)<br>**Value** | **Meaning** |
| --- | --- |
| [🔗](#tab:locale.codecvt.unshift-row-2)<br>ok | completed the sequence |
| [🔗](#tab:locale.codecvt.unshift-row-3)<br>partial | space for more than to_end - to destination elements was needed to terminate a sequence given the value of state |
| [🔗](#tab:locale.codecvt.unshift-row-4)<br>error | an unspecified error has occurred |
| [🔗](#tab:locale.codecvt.unshift-row-5)<br>noconv | no termination is needed for this state_type |
[🔗](#lib:codecvt,do_encoding)
`int do_encoding() const noexcept;
`
[10](#virtuals-10)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L2293)
*Returns*: -1 if the encoding of the externT sequence is state-dependent;
else the constant number of externT characters
needed to produce an internal character;
or 0 if this number is not a constant[.](#virtuals-10.sentence-1)[222](#footnote-222 "If encoding() yields -1, then more than max_­length() externT elements can be consumed when producing a single internT character, and additional externT elements can appear at the end of a sequence after those that yield the final internT character.")
[🔗](#lib:codecvt,do_always_noconv)
`bool do_always_noconv() const noexcept;
`
[11](#virtuals-11)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L2314)
*Returns*: true if do_in() and do_out() return noconv for all valid argument values[.](#virtuals-11.sentence-1)
codecvt<char, char, mbstate_t> returns true[.](#virtuals-11.sentence-2)
[🔗](#lib:codecvt,do_length)
`int do_length(stateT& state, const externT* from, const externT* from_end, size_t max) const;
`
[12](#virtuals-12)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L2327)
*Preconditions*: (from <= from_end) is well-defined and true;state is initialized, if at the beginning of a sequence,
or else is equal to the result of converting
the preceding characters in the sequence[.](#virtuals-12.sentence-1)
[13](#virtuals-13)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L2334)
*Effects*: The effect on the state argument is as if
it called do_in(state, from, from_end, from, to, to + max, to) for to pointing to a buffer of at least max elements[.](#virtuals-13.sentence-1)
[14](#virtuals-14)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L2340)
*Returns*: (from_next - from) wherefrom_next is the largest value in the range [from, from_end]
such that the sequence of values in the range [from, from_next)
representsmax or fewer valid complete characters of type internT[.](#virtuals-14.sentence-1)
The specialization codecvt<char, char, mbstate_t>,
returns the lesser of max and (from_end - from)[.](#virtuals-14.sentence-2)
[🔗](#lib:codecvt,do_max_length)
`int do_max_length() const noexcept;
`
[15](#virtuals-15)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L2357)
*Returns*: The maximum value that do_length(state, from, from_end, 1) can return
for any valid range [from, from_end)
and stateT value state[.](#virtuals-15.sentence-1)
The specialization codecvt<char, char, mbstate_t>::do_max_length() returns 1[.](#virtuals-15.sentence-2)
[220)](#footnote-220)[220)](#footnoteref-220)
Informally, this means that basic_filebuf assumes that the mappings from internal to external characters is 1 to N:
that a codecvt facet that is used by basic_filebuf can translate characters one internal character at a time[.](#footnote-220.sentence-1)
[221)](#footnote-221)[221)](#footnoteref-221)
Typically these will be characters to return the state to stateT()[.](#footnote-221.sentence-1)
[222)](#footnote-222)[222)](#footnoteref-222)
If encoding() yields -1,
then more than max_length() externT elements
can be consumed when producing a single internT character, and
additional externT elements can appear at the end of a sequence
after those that yield the final internT character[.](#footnote-222.sentence-1)

View File

@@ -0,0 +1,15 @@
[locale.codecvt.byname]
# 28 Text processing library [[text]](./#text)
## 28.3 Localization library [[localization]](localization#locale.codecvt.byname)
### 28.3.4 Standard locale categories [[locale.categories]](locale.categories#locale.codecvt.byname)
#### 28.3.4.2 The ctype category [[category.ctype]](category.ctype#locale.codecvt.byname)
#### 28.3.4.2.6 Class template codecvt_byname [locale.codecvt.byname]
[🔗](#lib:codecvt_byname)
namespace std {template<class internT, class externT, class stateT>class codecvt_byname : public codecvt<internT, externT, stateT> {public:explicit codecvt_byname(const char*, size_t refs = 0); explicit codecvt_byname(const string&, size_t refs = 0); protected:~codecvt_byname(); };}

View File

@@ -0,0 +1,67 @@
[locale.codecvt.general]
# 28 Text processing library [[text]](./#text)
## 28.3 Localization library [[localization]](localization#locale.codecvt.general)
### 28.3.4 Standard locale categories [[locale.categories]](locale.categories#locale.codecvt.general)
#### 28.3.4.2 The ctype category [[category.ctype]](category.ctype#locale.codecvt.general)
#### 28.3.4.2.5 Class template codecvt [[locale.codecvt]](locale.codecvt#general)
#### 28.3.4.2.5.1 General [locale.codecvt.general]
[🔗](#lib:codecvt)
namespace std {class codecvt_base {public:enum result { ok, partial, error, noconv }; }; template<class internT, class externT, class stateT>class codecvt : public locale::facet, public codecvt_base {public:using intern_type = internT; using extern_type = externT; using state_type = stateT; explicit codecvt(size_t refs = 0);
result out( stateT& state, const internT* from, const internT* from_end, const internT*& from_next,
externT* to, externT* to_end, externT*& to_next) const;
result unshift( stateT& state,
externT* to, externT* to_end, externT*& to_next) const;
result in( stateT& state, const externT* from, const externT* from_end, const externT*& from_next,
internT* to, internT* to_end, internT*& to_next) const; int encoding() const noexcept; bool always_noconv() const noexcept; int length(stateT&, const externT* from, const externT* end, size_t max) const; int max_length() const noexcept; static locale::id id; protected:~codecvt(); virtual result do_out( stateT& state, const internT* from, const internT* from_end, const internT*& from_next,
externT* to, externT* to_end, externT*& to_next) const; virtual result do_in( stateT& state, const externT* from, const externT* from_end, const externT*& from_next,
internT* to, internT* to_end, internT*& to_next) const; virtual result do_unshift( stateT& state,
externT* to, externT* to_end, externT*& to_next) const; virtual int do_encoding() const noexcept; virtual bool do_always_noconv() const noexcept; virtual int do_length(stateT&, const externT* from, const externT* end, size_t max) const; virtual int do_max_length() const noexcept; };}
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L2017)
The class codecvt<internT, externT, stateT> is for use
when converting from one character encoding to another,
such as from wide characters to multibyte characters or
between wide character encodings such as UTF-32 and EUC[.](#1.sentence-1)
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L2023)
The stateT argument selects
the pair of character encodings being mapped between[.](#2.sentence-1)
[3](#3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L2027)
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"))
convert the implementation-defined native character set[.](#3.sentence-1)
codecvt<char, char, mbstate_t> implements a degenerate conversion;
it does not convert at all[.](#3.sentence-2)
codecvt<wchar_t, char, mbstate_t> converts between the native character sets for ordinary and wide characters[.](#3.sentence-3)
Specializations on mbstate_t perform conversion between encodings known to the library implementer[.](#3.sentence-4)
Other encodings can be converted by specializing on
a program-defined stateT type[.](#3.sentence-5)
Objects of type stateT can contain any state
that is useful to communicate to or from
the specialized do_in or do_out members[.](#3.sentence-6)

View File

@@ -0,0 +1,96 @@
[locale.codecvt.members]
# 28 Text processing library [[text]](./#text)
## 28.3 Localization library [[localization]](localization#locale.codecvt.members)
### 28.3.4 Standard locale categories [[locale.categories]](locale.categories#locale.codecvt.members)
#### 28.3.4.2 The ctype category [[category.ctype]](category.ctype#locale.codecvt.members)
#### 28.3.4.2.5 Class template codecvt [[locale.codecvt]](locale.codecvt#members)
#### 28.3.4.2.5.2 Members [locale.codecvt.members]
[🔗](#lib:codecvt,out)
`result out(
stateT& state,
const internT* from, const internT* from_end, const internT*& from_next,
externT* to, externT* to_end, externT*& to_next) const;
`
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L2054)
*Returns*: do_out(state, from, from_end, from_next, to, to_end, to_next)[.](#1.sentence-1)
[🔗](#lib:codecvt,unshift)
`result unshift(stateT& state, externT* to, externT* to_end, externT*& to_next) const;
`
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L2065)
*Returns*: do_unshift(state, to, to_end, to_next)[.](#2.sentence-1)
[🔗](#lib:codecvt,in)
`result in(
stateT& state,
const externT* from, const externT* from_end, const externT*& from_next,
internT* to, internT* to_end, internT*& to_next) const;
`
[3](#3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L2079)
*Returns*: do_in(state, from, from_end, from_next, to, to_end, to_next)[.](#3.sentence-1)
[🔗](#lib:codecvt,encoding)
`int encoding() const noexcept;
`
[4](#4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L2090)
*Returns*: do_encoding()[.](#4.sentence-1)
[🔗](#lib:codecvt,always_noconv)
`bool always_noconv() const noexcept;
`
[5](#5)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L2101)
*Returns*: do_always_noconv()[.](#5.sentence-1)
[🔗](#lib:codecvt,length)
`int length(stateT& state, const externT* from, const externT* from_end, size_t max) const;
`
[6](#6)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L2112)
*Returns*: do_length(state, from, from_end, max)[.](#6.sentence-1)
[🔗](#lib:codecvt,max_length)
`int max_length() const noexcept;
`
[7](#7)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L2123)
*Returns*: do_max_length()[.](#7.sentence-1)

View File

@@ -0,0 +1,247 @@
[locale.codecvt.virtuals]
# 28 Text processing library [[text]](./#text)
## 28.3 Localization library [[localization]](localization#locale.codecvt.virtuals)
### 28.3.4 Standard locale categories [[locale.categories]](locale.categories#locale.codecvt.virtuals)
#### 28.3.4.2 The ctype category [[category.ctype]](category.ctype#locale.codecvt.virtuals)
#### 28.3.4.2.5 Class template codecvt [[locale.codecvt]](locale.codecvt#virtuals)
#### 28.3.4.2.5.3 Virtual functions [locale.codecvt.virtuals]
[🔗](#lib:codecvt,do_out)
`result do_out(
stateT& state,
const internT* from, const internT* from_end, const internT*& from_next,
externT* to, externT* to_end, externT*& to_next) const;
result do_in(
stateT& state,
const externT* from, const externT* from_end, const externT*& from_next,
internT* to, internT* to_end, internT*& to_next) const;
`
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L2145)
*Preconditions*: (from <= from_end && to <= to_end) is well-defined and true;state is initialized, if at the beginning of a sequence,
or else is equal to the result of converting
the preceding characters in the sequence[.](#1.sentence-1)
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L2152)
*Effects*: Translates characters in the source range [from, from_end),
placing the results in sequential positions starting at destination to[.](#2.sentence-1)
Converts no more than (from_end - from) source elements, and
stores no more than (to_end - to) destination elements[.](#2.sentence-2)
[3](#3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L2159)
Stops if it encounters a character it cannot convert[.](#3.sentence-1)
It always leaves the from_next and to_next pointers
pointing one beyond the last element successfully converted[.](#3.sentence-2)
If it returns noconv,internT and externT are the same type, and
the converted sequence is identical to
the input sequence [from, from_next),to_next is set equal to to,
the value of state is unchanged, and
there are no changes to the values in [to, to_end)[.](#3.sentence-3)
[4](#4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L2171)
A codecvt facet
that is used by basic_filebuf ([[file.streams]](file.streams "31.10File-based streams"))
shall have the property that ifdo_out(state, from, from_end, from_next, to, to_end, to_next) would return ok,
where from != from_end,
thendo_out(state, from, from + 1, from_next, to, to_end, to_next) shall also return ok,
and that ifdo_in(state, from, from_end, from_next, to, to_end, to_next) would return ok,
where to != to_end,
thendo_in(state, from, from_end, from_next, to, to + 1, to_next) shall also return ok[.](#4.sentence-1)[220](#footnote-220 "Informally, this means that basic_­filebuf assumes that the mappings from internal to external characters is 1 to N: that a codecvt facet that is used by basic_­filebuf can translate characters one internal character at a time.")
[*Note [1](#note-1)*:
As a result of operations on state,
it can return ok or partial and
set from_next == from and to_next != to[.](#4.sentence-2)
— *end note*]
[5](#5)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L2208)
*Returns*: An enumeration value, as summarized in Table [93](#tab:locale.codecvt.inout "Table 93: do_­in/do_­out result values")[.](#5.sentence-1)
Table [93](#tab:locale.codecvt.inout) — do_in/do_out result values [[tab:locale.codecvt.inout]](./tab:locale.codecvt.inout)
| [🔗](#tab:locale.codecvt.inout-row-1)<br>**Value** | **Meaning** |
| --- | --- |
| [🔗](#tab:locale.codecvt.inout-row-2)<br>ok | completed the conversion |
| [🔗](#tab:locale.codecvt.inout-row-3)<br>partial | not all source characters converted |
| [🔗](#tab:locale.codecvt.inout-row-4)<br>error | encountered a character in [from, from_end) that cannot be converted |
| [🔗](#tab:locale.codecvt.inout-row-5)<br>noconv | internT and externT are the same type, and input sequence is identical to converted sequence |
A return value of partial,
if (from_next == from_end),
indicates
that either the destination sequence has not absorbed
all the available destination elements, or
that additional source elements are needed
before another destination element can be produced[.](#5.sentence-2)
[6](#6)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L2234)
*Remarks*: Its operations on state are unspecified[.](#6.sentence-1)
[*Note [2](#note-2)*:
This argument can be used, for example,
to maintain shift state,
to specify conversion options (such as count only), or
to identify a cache of seek offsets[.](#6.sentence-2)
— *end note*]
[🔗](#lib:codecvt,do_unshift)
`result do_unshift(stateT& state, externT* to, externT* to_end, externT*& to_next) const;
`
[7](#7)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L2251)
*Preconditions*: (to <= to_end) is well-defined and true;state is initialized, if at the beginning of a sequence,
or else is equal to the result of converting
the preceding characters in the sequence[.](#7.sentence-1)
[8](#8)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L2258)
*Effects*: Places characters starting at to that should be appended to terminate a sequence
when the current stateT is given by state[.](#8.sentence-1)[221](#footnote-221 "Typically these will be characters to return the state to stateT().")
Stores no more than (to_end - to) destination elements, and
leaves the to_next pointer
pointing one beyond the last element successfully stored[.](#8.sentence-2)
[9](#9)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L2270)
*Returns*: An enumeration value, as summarized in Table [94](#tab:locale.codecvt.unshift "Table 94: do_­unshift result values")[.](#9.sentence-1)
Table [94](#tab:locale.codecvt.unshift) — do_unshift result values [[tab:locale.codecvt.unshift]](./tab:locale.codecvt.unshift)
| [🔗](#tab:locale.codecvt.unshift-row-1)<br>**Value** | **Meaning** |
| --- | --- |
| [🔗](#tab:locale.codecvt.unshift-row-2)<br>ok | completed the sequence |
| [🔗](#tab:locale.codecvt.unshift-row-3)<br>partial | space for more than to_end - to destination elements was needed to terminate a sequence given the value of state |
| [🔗](#tab:locale.codecvt.unshift-row-4)<br>error | an unspecified error has occurred |
| [🔗](#tab:locale.codecvt.unshift-row-5)<br>noconv | no termination is needed for this state_type |
[🔗](#lib:codecvt,do_encoding)
`int do_encoding() const noexcept;
`
[10](#10)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L2293)
*Returns*: -1 if the encoding of the externT sequence is state-dependent;
else the constant number of externT characters
needed to produce an internal character;
or 0 if this number is not a constant[.](#10.sentence-1)[222](#footnote-222 "If encoding() yields -1, then more than max_­length() externT elements can be consumed when producing a single internT character, and additional externT elements can appear at the end of a sequence after those that yield the final internT character.")
[🔗](#lib:codecvt,do_always_noconv)
`bool do_always_noconv() const noexcept;
`
[11](#11)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L2314)
*Returns*: true if do_in() and do_out() return noconv for all valid argument values[.](#11.sentence-1)
codecvt<char, char, mbstate_t> returns true[.](#11.sentence-2)
[🔗](#lib:codecvt,do_length)
`int do_length(stateT& state, const externT* from, const externT* from_end, size_t max) const;
`
[12](#12)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L2327)
*Preconditions*: (from <= from_end) is well-defined and true;state is initialized, if at the beginning of a sequence,
or else is equal to the result of converting
the preceding characters in the sequence[.](#12.sentence-1)
[13](#13)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L2334)
*Effects*: The effect on the state argument is as if
it called do_in(state, from, from_end, from, to, to + max, to) for to pointing to a buffer of at least max elements[.](#13.sentence-1)
[14](#14)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L2340)
*Returns*: (from_next - from) wherefrom_next is the largest value in the range [from, from_end]
such that the sequence of values in the range [from, from_next)
representsmax or fewer valid complete characters of type internT[.](#14.sentence-1)
The specialization codecvt<char, char, mbstate_t>,
returns the lesser of max and (from_end - from)[.](#14.sentence-2)
[🔗](#lib:codecvt,do_max_length)
`int do_max_length() const noexcept;
`
[15](#15)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L2357)
*Returns*: The maximum value that do_length(state, from, from_end, 1) can return
for any valid range [from, from_end)
and stateT value state[.](#15.sentence-1)
The specialization codecvt<char, char, mbstate_t>::do_max_length() returns 1[.](#15.sentence-2)
[220)](#footnote-220)[220)](#footnoteref-220)
Informally, this means that basic_filebuf assumes that the mappings from internal to external characters is 1 to N:
that a codecvt facet that is used by basic_filebuf can translate characters one internal character at a time[.](#footnote-220.sentence-1)
[221)](#footnote-221)[221)](#footnoteref-221)
Typically these will be characters to return the state to stateT()[.](#footnote-221.sentence-1)
[222)](#footnote-222)[222)](#footnoteref-222)
If encoding() yields -1,
then more than max_length() externT elements
can be consumed when producing a single internT character, and
additional externT elements can appear at the end of a sequence
after those that yield the final internT character[.](#footnote-222.sentence-1)

135
cppdraft/locale/collate.md Normal file
View File

@@ -0,0 +1,135 @@
[locale.collate]
# 28 Text processing library [[text]](./#text)
## 28.3 Localization library [[localization]](localization#locale.collate)
### 28.3.4 Standard locale categories [[locale.categories]](locale.categories#locale.collate)
#### 28.3.4.5 The collate category [[category.collate]](category.collate#locale.collate)
#### 28.3.4.5.1 Class template collate [locale.collate]
#### [28.3.4.5.1.1](#general) General [[locale.collate.general]](locale.collate.general)
[🔗](#lib:collate)
namespace std {template<class charT>class collate : public locale::facet {public:using char_type = charT; using string_type = basic_string<charT>; explicit collate(size_t refs = 0); int compare(const charT* low1, const charT* high1, const charT* low2, const charT* high2) const;
string_type transform(const charT* low, const charT* high) const; long hash(const charT* low, const charT* high) const; static locale::id id; protected:~collate(); virtual int do_compare(const charT* low1, const charT* high1, const charT* low2, const charT* high2) const; virtual string_type do_transform(const charT* low, const charT* high) const; virtual long do_hash (const charT* low, const charT* high) const; };}
[1](#general-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L3381)
The class collate<charT> provides features
for use in the collation (comparison) and hashing of strings[.](#general-1.sentence-1)
A locale member function template, operator(),
uses the collate facet to allow a locale to act directly as
the predicate argument for standard algorithms ([[algorithms]](algorithms "26Algorithms library")) and
containers operating on strings[.](#general-1.sentence-2)
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 collate<char> and collate<wchar_t>,
apply lexicographical ordering ([[alg.lex.comparison]](alg.lex.comparison "26.8.11Lexicographical comparison"))[.](#general-1.sentence-3)
[2](#general-2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L3393)
Each function compares a string of characters *p in the range [low, high)[.](#general-2.sentence-1)
#### [28.3.4.5.1.2](#members) Members [[locale.collate.members]](locale.collate.members)
[🔗](#lib:collate,compare)
`int compare(const charT* low1, const charT* high1,
const charT* low2, const charT* high2) const;
`
[1](#members-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L3406)
*Returns*: do_compare(low1, high1, low2, high2)[.](#members-1.sentence-1)
[🔗](#lib:collate,transform)
`string_type transform(const charT* low, const charT* high) const;
`
[2](#members-2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L3417)
*Returns*: do_transform(low, high)[.](#members-2.sentence-1)
[🔗](#lib:collate,hash)
`long hash(const charT* low, const charT* high) const;
`
[3](#members-3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L3428)
*Returns*: do_hash(low, high)[.](#members-3.sentence-1)
#### [28.3.4.5.1.3](#virtuals) Virtual functions [[locale.collate.virtuals]](locale.collate.virtuals)
[🔗](#lib:collate,do_compare)
`int do_compare(const charT* low1, const charT* high1,
const charT* low2, const charT* high2) const;
`
[1](#virtuals-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L3442)
*Returns*: 1 if the first string is greater than the second,-1 if less,
zero otherwise[.](#virtuals-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 collate<char> and collate<wchar_t>,
implement a lexicographical comparison ([[alg.lex.comparison]](alg.lex.comparison "26.8.11Lexicographical comparison"))[.](#virtuals-1.sentence-2)
[🔗](#lib:collate,do_transform)
`string_type do_transform(const charT* low, const charT* high) const;
`
[2](#virtuals-2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L3459)
*Returns*: A basic_string<charT> value that,
compared lexicographically with
the result of calling transform() on another string,
yields the same result as calling do_compare() on the same two strings[.](#virtuals-2.sentence-1)[226](#footnote-226 "This function is useful when one string is being compared to many other strings.")
[🔗](#lib:collate,do_hash)
`long do_hash(const charT* low, const charT* high) const;
`
[3](#virtuals-3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L3476)
*Returns*: An integer value equal to the result of calling hash() on any other string for which do_compare() returns 0 (equal)
when passed the two strings[.](#virtuals-3.sentence-1)
[4](#virtuals-4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L3482)
*Recommended practice*: The probability that the result equals that for another string
which does not compare equal should be very small,
approaching (1.0/numeric_limits<unsigned long>::max())[.](#virtuals-4.sentence-1)
[226)](#footnote-226)[226)](#footnoteref-226)
This function is useful when one string is being compared to many other strings[.](#footnote-226.sentence-1)

View File

@@ -0,0 +1,15 @@
[locale.collate.byname]
# 28 Text processing library [[text]](./#text)
## 28.3 Localization library [[localization]](localization#locale.collate.byname)
### 28.3.4 Standard locale categories [[locale.categories]](locale.categories#locale.collate.byname)
#### 28.3.4.5 The collate category [[category.collate]](category.collate#locale.collate.byname)
#### 28.3.4.5.2 Class template collate_byname [locale.collate.byname]
[🔗](#lib:collate_byname)
namespace std {template<class charT>class collate_byname : public collate<charT> {public:using string_type = basic_string<charT>; explicit collate_byname(const char*, size_t refs = 0); explicit collate_byname(const string&, size_t refs = 0); protected:~collate_byname(); };}

View File

@@ -0,0 +1,41 @@
[locale.collate.general]
# 28 Text processing library [[text]](./#text)
## 28.3 Localization library [[localization]](localization#locale.collate.general)
### 28.3.4 Standard locale categories [[locale.categories]](locale.categories#locale.collate.general)
#### 28.3.4.5 The collate category [[category.collate]](category.collate#locale.collate.general)
#### 28.3.4.5.1 Class template collate [[locale.collate]](locale.collate#general)
#### 28.3.4.5.1.1 General [locale.collate.general]
[🔗](#lib:collate)
namespace std {template<class charT>class collate : public locale::facet {public:using char_type = charT; using string_type = basic_string<charT>; explicit collate(size_t refs = 0); int compare(const charT* low1, const charT* high1, const charT* low2, const charT* high2) const;
string_type transform(const charT* low, const charT* high) const; long hash(const charT* low, const charT* high) const; static locale::id id; protected:~collate(); virtual int do_compare(const charT* low1, const charT* high1, const charT* low2, const charT* high2) const; virtual string_type do_transform(const charT* low, const charT* high) const; virtual long do_hash (const charT* low, const charT* high) const; };}
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L3381)
The class collate<charT> provides features
for use in the collation (comparison) and hashing of strings[.](#1.sentence-1)
A locale member function template, operator(),
uses the collate facet to allow a locale to act directly as
the predicate argument for standard algorithms ([[algorithms]](algorithms "26Algorithms library")) and
containers operating on strings[.](#1.sentence-2)
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 collate<char> and collate<wchar_t>,
apply lexicographical ordering ([[alg.lex.comparison]](alg.lex.comparison "26.8.11Lexicographical comparison"))[.](#1.sentence-3)
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L3393)
Each function compares a string of characters *p in the range [low, high)[.](#2.sentence-1)

View File

@@ -0,0 +1,47 @@
[locale.collate.members]
# 28 Text processing library [[text]](./#text)
## 28.3 Localization library [[localization]](localization#locale.collate.members)
### 28.3.4 Standard locale categories [[locale.categories]](locale.categories#locale.collate.members)
#### 28.3.4.5 The collate category [[category.collate]](category.collate#locale.collate.members)
#### 28.3.4.5.1 Class template collate [[locale.collate]](locale.collate#members)
#### 28.3.4.5.1.2 Members [locale.collate.members]
[🔗](#lib:collate,compare)
`int compare(const charT* low1, const charT* high1,
const charT* low2, const charT* high2) const;
`
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L3406)
*Returns*: do_compare(low1, high1, low2, high2)[.](#1.sentence-1)
[🔗](#lib:collate,transform)
`string_type transform(const charT* low, const charT* high) const;
`
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L3417)
*Returns*: do_transform(low, high)[.](#2.sentence-1)
[🔗](#lib:collate,hash)
`long hash(const charT* low, const charT* high) const;
`
[3](#3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L3428)
*Returns*: do_hash(low, high)[.](#3.sentence-1)

View File

@@ -0,0 +1,69 @@
[locale.collate.virtuals]
# 28 Text processing library [[text]](./#text)
## 28.3 Localization library [[localization]](localization#locale.collate.virtuals)
### 28.3.4 Standard locale categories [[locale.categories]](locale.categories#locale.collate.virtuals)
#### 28.3.4.5 The collate category [[category.collate]](category.collate#locale.collate.virtuals)
#### 28.3.4.5.1 Class template collate [[locale.collate]](locale.collate#virtuals)
#### 28.3.4.5.1.3 Virtual functions [locale.collate.virtuals]
[🔗](#lib:collate,do_compare)
`int do_compare(const charT* low1, const charT* high1,
const charT* low2, const charT* high2) const;
`
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L3442)
*Returns*: 1 if the first string is greater than the second,-1 if less,
zero otherwise[.](#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 collate<char> and collate<wchar_t>,
implement a lexicographical comparison ([[alg.lex.comparison]](alg.lex.comparison "26.8.11Lexicographical comparison"))[.](#1.sentence-2)
[🔗](#lib:collate,do_transform)
`string_type do_transform(const charT* low, const charT* high) const;
`
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L3459)
*Returns*: A basic_string<charT> value that,
compared lexicographically with
the result of calling transform() on another string,
yields the same result as calling do_compare() on the same two strings[.](#2.sentence-1)[226](#footnote-226 "This function is useful when one string is being compared to many other strings.")
[🔗](#lib:collate,do_hash)
`long do_hash(const charT* low, const charT* high) const;
`
[3](#3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L3476)
*Returns*: An integer value equal to the result of calling hash() on any other string for which do_compare() returns 0 (equal)
when passed the two strings[.](#3.sentence-1)
[4](#4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L3482)
*Recommended practice*: The probability that the result equals that for another string
which does not compare equal should be very small,
approaching (1.0/numeric_limits<unsigned long>::max())[.](#4.sentence-1)
[226)](#footnote-226)[226)](#footnoteref-226)
This function is useful when one string is being compared to many other strings[.](#footnote-226.sentence-1)

182
cppdraft/locale/cons.md Normal file
View File

@@ -0,0 +1,182 @@
[locale.cons]
# 28 Text processing library [[text]](./#text)
## 28.3 Localization library [[localization]](localization#locale.cons)
### 28.3.3 Locales [[locales]](locales#locale.cons)
#### 28.3.3.1 Class locale [[locale]](locale#cons)
#### 28.3.3.1.3 Constructors and destructor [locale.cons]
[🔗](#lib:locale,constructor)
`locale() noexcept;
`
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L865)
*Effects*: Constructs a copy of the argument last passed tolocale::global(locale&),
if it has been called;
else, the resulting facets have virtual function semantics identical to
those of locale::classic()[.](#1.sentence-1)
[*Note [1](#note-1)*:
This constructor yields a copy of the current global locale[.](#1.sentence-2)
It is commonly used as a default argument for
function parameters of type const locale&[.](#1.sentence-3)
— *end note*]
[🔗](#lib:locale,constructor_)
`explicit locale(const char* std_name);
`
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L885)
*Effects*: Constructs a locale using standard C locale names, e.g., "POSIX"[.](#2.sentence-1)
The resulting locale implements semantics defined to be associated
with that name[.](#2.sentence-2)
[3](#3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L891)
*Throws*: runtime_error if the argument is not valid, or is null[.](#3.sentence-1)
[4](#4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L895)
*Remarks*: The set of valid string argument values is"C", "", and any implementation-defined values[.](#4.sentence-1)
[🔗](#lib:locale,constructor__)
`explicit locale(const string& std_name);
`
[5](#5)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L907)
*Effects*: Equivalent to locale(std_name.c_str())[.](#5.sentence-1)
[🔗](#lib:locale,constructor___)
`locale(const locale& other, const char* std_name, category cats);
`
[6](#6)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L918)
*Preconditions*: cats is a valid category value ([[locale.category]](locale.category "28.3.3.1.2.1Type locale::category"))[.](#6.sentence-1)
[7](#7)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L922)
*Effects*: Constructs a locale as a copy of other except for the facets identified by the category argument,
which instead implement the same semantics as locale(std_name)[.](#7.sentence-1)
[8](#8)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L928)
*Throws*: runtime_error if the second argument is not valid, or is null[.](#8.sentence-1)
[9](#9)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L932)
*Remarks*: The locale has a name if and only if other has a name[.](#9.sentence-1)
[🔗](#lib:locale,constructor____)
`locale(const locale& other, const string& std_name, category cats);
`
[10](#10)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L943)
*Effects*: Equivalent to locale(other, std_name.c_str(), cats)[.](#10.sentence-1)
[🔗](#lib:locale,constructor_____)
`template<class Facet> locale(const locale& other, Facet* f);
`
[11](#11)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L954)
*Effects*: Constructs a locale incorporating all facets from the first argument
except that of type Facet,
and installs the second argument as the remaining facet[.](#11.sentence-1)
If f is null, the resulting object is a copy of other[.](#11.sentence-2)
[12](#12)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L961)
*Remarks*: If f is null,
the resulting locale has the same name as other[.](#12.sentence-1)
Otherwise, the resulting locale has no name[.](#12.sentence-2)
[🔗](#lib:locale,constructor______)
`locale(const locale& other, const locale& one, category cats);
`
[13](#13)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L974)
*Preconditions*: cats is a valid category value[.](#13.sentence-1)
[14](#14)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L978)
*Effects*: Constructs a locale incorporating all facets from the first argument
except those that implement cats,
which are instead incorporated from the second argument[.](#14.sentence-1)
[15](#15)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L984)
*Remarks*: If cats is equal to locale::none,
the resulting locale has a name if and only if the first argument has a name[.](#15.sentence-1)
Otherwise, the resulting locale has a name if and only if
the first two arguments both have names[.](#15.sentence-2)
[🔗](#lib:operator=,locale)
`const locale& operator=(const locale& other) noexcept;
`
[16](#16)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L998)
*Effects*: Creates a copy of other, replacing the current value[.](#16.sentence-1)
[17](#17)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L1002)
*Returns*: *this[.](#17.sentence-1)

View File

@@ -0,0 +1,64 @@
[locale.convenience]
# 28 Text processing library [[text]](./#text)
## 28.3 Localization library [[localization]](localization#locale.convenience)
### 28.3.3 Locales [[locales]](locales#locale.convenience)
#### 28.3.3.3 Convenience interfaces [locale.convenience]
#### [28.3.3.3.1](#classification) Character classification [[classification]](classification)
[🔗](#lib:isspace)
`template<class charT> bool isspace (charT c, const locale& loc);
template<class charT> bool isprint (charT c, const locale& loc);
template<class charT> bool iscntrl (charT c, const locale& loc);
template<class charT> bool isupper (charT c, const locale& loc);
template<class charT> bool islower (charT c, const locale& loc);
template<class charT> bool isalpha (charT c, const locale& loc);
template<class charT> bool isdigit (charT c, const locale& loc);
template<class charT> bool ispunct (charT c, const locale& loc);
template<class charT> bool isxdigit(charT c, const locale& loc);
template<class charT> bool isalnum (charT c, const locale& loc);
template<class charT> bool isgraph (charT c, const locale& loc);
template<class charT> bool isblank (charT c, const locale& loc);
`
[1](#classification-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L1240)
Each of these functions is*F* returns the result of the expression:use_facet<ctype<charT>>(loc).is(ctype_base::*F*, c) where *F* is the ctype_base::mask value
corresponding to that function ([[category.ctype]](category.ctype "28.3.4.2The ctype category"))[.](#classification-1.sentence-1)[216](#footnote-216 "When used in a loop, it is faster to cache the ctype&lt;> facet and use it directly, or use the vector form of ctype&lt;>::is.")
[216)](#footnote-216)[216)](#footnoteref-216)
When used in a loop,
it is faster to cache the ctype<> facet and use it directly, or
use the vector form of ctype<>::is[.](#footnote-216.sentence-1)
#### [28.3.3.3.2](#conversions.character) Character conversions [[conversions.character]](conversions.character)
[🔗](#lib:toupper)
`template<class charT> charT toupper(charT c, const locale& loc);
`
[1](#conversions.character-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L1262)
*Returns*: use_facet<ctype<charT>>(loc).toupper(c)[.](#conversions.character-1.sentence-1)
[🔗](#lib:tolower)
`template<class charT> charT tolower(charT c, const locale& loc);
`
[2](#conversions.character-2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L1273)
*Returns*: use_facet<ctype<charT>>(loc).tolower(c)[.](#conversions.character-2.sentence-1)

326
cppdraft/locale/ctype.md Normal file
View File

@@ -0,0 +1,326 @@
[locale.ctype]
# 28 Text processing library [[text]](./#text)
## 28.3 Localization library [[localization]](localization#locale.ctype)
### 28.3.4 Standard locale categories [[locale.categories]](locale.categories#locale.ctype)
#### 28.3.4.2 The ctype category [[category.ctype]](category.ctype#locale.ctype)
#### 28.3.4.2.2 Class template ctype [locale.ctype]
#### [28.3.4.2.2.1](#general) General [[locale.ctype.general]](locale.ctype.general)
[🔗](#lib:ctype)
namespace std {template<class charT>class ctype : public locale::facet, public ctype_base {public:using char_type = charT; explicit ctype(size_t refs = 0); bool is(mask m, charT c) const; const charT* is(const charT* low, const charT* high, mask* vec) const; const charT* scan_is(mask m, const charT* low, const charT* high) const; const charT* scan_not(mask m, const charT* low, const charT* high) const;
charT toupper(charT c) const; const charT* toupper(charT* low, const charT* high) const;
charT tolower(charT c) const; const charT* tolower(charT* low, const charT* high) const;
charT widen(char c) const; const char* widen(const char* low, const char* high, charT* to) const; char narrow(charT c, char dfault) const; const charT* narrow(const charT* low, const charT* high, char dfault, char* to) const; static locale::id id; protected:~ctype(); virtual bool do_is(mask m, charT c) const; virtual const charT* do_is(const charT* low, const charT* high, mask* vec) const; virtual const charT* do_scan_is(mask m, const charT* low, const charT* high) const; virtual const charT* do_scan_not(mask m, const charT* low, const charT* high) const; virtual charT do_toupper(charT) const; virtual const charT* do_toupper(charT* low, const charT* high) const; virtual charT do_tolower(charT) const; virtual const charT* do_tolower(charT* low, const charT* high) const; virtual charT do_widen(char) const; virtual const char* do_widen(const char* low, const char* high, charT* dest) const; virtual char do_narrow(charT, char dfault) const; virtual const charT* do_narrow(const charT* low, const charT* high, char dfault, char* dest) const; };}
[1](#general-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L1395)
Class ctype encapsulates the C library [<cctype>](cctype.syn#header:%3ccctype%3e "28.7.1Header <cctype> synopsis[cctype.syn]") features[.](#general-1.sentence-1)
istream members are required to use ctype<> for character classing during input parsing[.](#general-1.sentence-2)
[2](#general-2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L1400)
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 ctype<char> and ctype<wchar_t>,
implement character classing appropriate
to the implementation's native character set[.](#general-2.sentence-1)
#### [28.3.4.2.2.2](#members) ctype members [[locale.ctype.members]](locale.ctype.members)
[🔗](#lib:ctype,is)
`bool is(mask m, charT c) const;
const charT* is(const charT* low, const charT* high, mask* vec) const;
`
[1](#members-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L1416)
*Returns*: do_is(m, c) or do_is(low, high, vec)[.](#members-1.sentence-1)
[🔗](#lib:ctype,scan_is)
`const charT* scan_is(mask m, const charT* low, const charT* high) const;
`
[2](#members-2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L1427)
*Returns*: do_scan_is(m, low, high)[.](#members-2.sentence-1)
[🔗](#lib:ctype,scan_not)
`const charT* scan_not(mask m, const charT* low, const charT* high) const;
`
[3](#members-3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L1438)
*Returns*: do_scan_not(m, low, high)[.](#members-3.sentence-1)
[🔗](#lib:ctype,toupper)
`charT toupper(charT c) const;
const charT* toupper(charT* low, const charT* high) const;
`
[4](#members-4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L1450)
*Returns*: do_toupper(c) or do_toupper(low, high)[.](#members-4.sentence-1)
[🔗](#lib:ctype,tolower)
`charT tolower(charT c) const;
const charT* tolower(charT* low, const charT* high) const;
`
[5](#members-5)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L1462)
*Returns*: do_tolower(c) or do_tolower(low, high)[.](#members-5.sentence-1)
[🔗](#lib:ctype,widen)
`charT widen(char c) const;
const char* widen(const char* low, const char* high, charT* to) const;
`
[6](#members-6)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L1474)
*Returns*: do_widen(c) or do_widen(low, high, to)[.](#members-6.sentence-1)
[🔗](#lib:ctype,narrow)
`char narrow(charT c, char dfault) const;
const charT* narrow(const charT* low, const charT* high, char dfault, char* to) const;
`
[7](#members-7)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L1486)
*Returns*: do_narrow(c, dfault) or do_narrow(low, high, dfault, to)[.](#members-7.sentence-1)
#### [28.3.4.2.2.3](#virtuals) ctype virtual functions [[locale.ctype.virtuals]](locale.ctype.virtuals)
[🔗](#lib:ctype,do_is)
`bool do_is(mask m, charT c) const;
const charT* do_is(const charT* low, const charT* high, mask* vec) const;
`
[1](#virtuals-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L1500)
*Effects*: Classifies a character or sequence of characters[.](#virtuals-1.sentence-1)
For each argument character,
identifies a value M of type ctype_base::mask[.](#virtuals-1.sentence-2)
The second form identifies a value M of type ctype_base::mask for each *p where (low <= p && p < high),
and places it into vec[p - low][.](#virtuals-1.sentence-3)
[2](#virtuals-2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L1509)
*Returns*: The first form returns the result of the expression (M & m) != 0;
i.e., true if the character has the characteristics specified[.](#virtuals-2.sentence-1)
The second form returns high[.](#virtuals-2.sentence-2)
[🔗](#lib:ctype_base,do_scan_is)
`const charT* do_scan_is(mask m, const charT* low, const charT* high) const;
`
[3](#virtuals-3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L1522)
*Effects*: Locates a character in a buffer that conforms to a classification m[.](#virtuals-3.sentence-1)
[4](#virtuals-4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L1526)
*Returns*: The smallest pointer p in the range [low, high)
such that is(m, *p) would return true;
otherwise, returns high[.](#virtuals-4.sentence-1)
[🔗](#lib:ctype,do_scan_not)
`const charT* do_scan_not(mask m, const charT* low, const charT* high) const;
`
[5](#virtuals-5)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L1539)
*Effects*: Locates a character in a buffer that fails to conform to a classificationm[.](#virtuals-5.sentence-1)
[6](#virtuals-6)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L1544)
*Returns*: The smallest pointer p, if any, in the range [low, high)
such that is(m, *p) would return false;
otherwise, returns high[.](#virtuals-6.sentence-1)
[🔗](#lib:ctype,do_toupper)
`charT do_toupper(charT c) const;
const charT* do_toupper(charT* low, const charT* high) const;
`
[7](#virtuals-7)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L1558)
*Effects*: Converts a character or characters to upper case[.](#virtuals-7.sentence-1)
The second form replaces
each character *p in the range [low, high)
for which a corresponding upper-case character exists,
with that character[.](#virtuals-7.sentence-2)
[8](#virtuals-8)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L1566)
*Returns*: The first form returns
the corresponding upper-case character if it is known to exist, or
its argument if not[.](#virtuals-8.sentence-1)
The second form returns high[.](#virtuals-8.sentence-2)
[🔗](#lib:ctype,do_tolower)
`charT do_tolower(charT c) const;
const charT* do_tolower(charT* low, const charT* high) const;
`
[9](#virtuals-9)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L1581)
*Effects*: Converts a character or characters to lower case[.](#virtuals-9.sentence-1)
The second form replaces
each character *p in the range [low, high)
and for which a corresponding lower-case character exists,
with that character[.](#virtuals-9.sentence-2)
[10](#virtuals-10)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L1589)
*Returns*: The first form returns
the corresponding lower-case character if it is known to exist, or
its argument if not[.](#virtuals-10.sentence-1)
The second form returns high[.](#virtuals-10.sentence-2)
[🔗](#lib:ctype,do_widen)
`charT do_widen(char c) const;
const char* do_widen(const char* low, const char* high, charT* dest) const;
`
[11](#virtuals-11)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L1604)
*Effects*: Applies the simplest reasonable transformation
from a char value or sequence of char values
to the corresponding charT value or values[.](#virtuals-11.sentence-1)[217](#footnote-217 "The parameter c of do_­widen is intended to accept values derived from character-literals for conversion to the locale's encoding.")
The only characters for which unique transformations are required
are those in the basic character set ([[lex.charset]](lex.charset "5.3.1Character sets"))[.](#virtuals-11.sentence-2)
For any named ctype category with
a ctype<char> facet ctc and
valid ctype_base::mask value M,(ctc.is(M, c) || !is(M, do_widen(c)) ) is true[.](#virtuals-11.sentence-3)[218](#footnote-218 "In other words, the transformed character is not a member of any character classification that c is not also a member of.")
The second form transforms
each character *p in the range [low, high),
placing the result in dest[p - low][.](#virtuals-11.sentence-4)
[12](#virtuals-12)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L1631)
*Returns*: The first form returns the transformed value[.](#virtuals-12.sentence-1)
The second form returns high[.](#virtuals-12.sentence-2)
[🔗](#lib:ctype,do_narrow)
`char do_narrow(charT c, char dfault) const;
const charT* do_narrow(const charT* low, const charT* high, char dfault, char* dest) const;
`
[13](#virtuals-13)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L1644)
*Effects*: Applies the simplest reasonable transformation
from a charT value or sequence of charT values
to the corresponding char value or values[.](#virtuals-13.sentence-1)
For any character c in the basic character set ([[lex.charset]](lex.charset "5.3.1Character sets"))
the transformation is such thatdo_widen(do_narrow(c, 0)) == c
For any named ctype category with
a ctype<char> facet ctc however, andctype_base::mask value M,(is(M, c) || !ctc.is(M, do_narrow(c, dfault)) ) is true (unless do_narrow returns dfault)[.](#virtuals-13.sentence-3)
In addition, for any digit character c,
the expression (do_narrow(c, dfault) - '0') evaluates to the digit value of the character[.](#virtuals-13.sentence-4)
The second form transforms
each character *p in the range [low, high),
placing the result
(or dfault if no simple transformation is readily available)
in dest[p - low][.](#virtuals-13.sentence-5)
[14](#virtuals-14)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L1672)
*Returns*: The first form returns the transformed value;
or dfault if no mapping is readily available[.](#virtuals-14.sentence-1)
The second form returns high[.](#virtuals-14.sentence-2)
[217)](#footnote-217)[217)](#footnoteref-217)
The parameter c of do_widen is intended to
accept values derived from [*character-literal*](lex.ccon#nt:character-literal "5.13.3Character literals[lex.ccon]")*s* for conversion to the locale's encoding[.](#footnote-217.sentence-1)
[218)](#footnote-218)[218)](#footnoteref-218)
In other words, the transformed character is not
a member of any character classification
that c is not also a member of[.](#footnote-218.sentence-1)

View File

@@ -0,0 +1,15 @@
[locale.ctype.byname]
# 28 Text processing library [[text]](./#text)
## 28.3 Localization library [[localization]](localization#locale.ctype.byname)
### 28.3.4 Standard locale categories [[locale.categories]](locale.categories#locale.ctype.byname)
#### 28.3.4.2 The ctype category [[category.ctype]](category.ctype#locale.ctype.byname)
#### 28.3.4.2.3 Class template ctype_byname [locale.ctype.byname]
[🔗](#lib:ctype_byname)
namespace std {template<class charT>class ctype_byname : public ctype<charT> {public:using mask = typename ctype<charT>::mask; explicit ctype_byname(const char*, size_t refs = 0); explicit ctype_byname(const string&, size_t refs = 0); protected:~ctype_byname(); };}

View File

@@ -0,0 +1,39 @@
[locale.ctype.general]
# 28 Text processing library [[text]](./#text)
## 28.3 Localization library [[localization]](localization#locale.ctype.general)
### 28.3.4 Standard locale categories [[locale.categories]](locale.categories#locale.ctype.general)
#### 28.3.4.2 The ctype category [[category.ctype]](category.ctype#locale.ctype.general)
#### 28.3.4.2.2 Class template ctype [[locale.ctype]](locale.ctype#general)
#### 28.3.4.2.2.1 General [locale.ctype.general]
[🔗](#lib:ctype)
namespace std {template<class charT>class ctype : public locale::facet, public ctype_base {public:using char_type = charT; explicit ctype(size_t refs = 0); bool is(mask m, charT c) const; const charT* is(const charT* low, const charT* high, mask* vec) const; const charT* scan_is(mask m, const charT* low, const charT* high) const; const charT* scan_not(mask m, const charT* low, const charT* high) const;
charT toupper(charT c) const; const charT* toupper(charT* low, const charT* high) const;
charT tolower(charT c) const; const charT* tolower(charT* low, const charT* high) const;
charT widen(char c) const; const char* widen(const char* low, const char* high, charT* to) const; char narrow(charT c, char dfault) const; const charT* narrow(const charT* low, const charT* high, char dfault, char* to) const; static locale::id id; protected:~ctype(); virtual bool do_is(mask m, charT c) const; virtual const charT* do_is(const charT* low, const charT* high, mask* vec) const; virtual const charT* do_scan_is(mask m, const charT* low, const charT* high) const; virtual const charT* do_scan_not(mask m, const charT* low, const charT* high) const; virtual charT do_toupper(charT) const; virtual const charT* do_toupper(charT* low, const charT* high) const; virtual charT do_tolower(charT) const; virtual const charT* do_tolower(charT* low, const charT* high) const; virtual charT do_widen(char) const; virtual const char* do_widen(const char* low, const char* high, charT* dest) const; virtual char do_narrow(charT, char dfault) const; virtual const charT* do_narrow(const charT* low, const charT* high, char dfault, char* dest) const; };}
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L1395)
Class ctype encapsulates the C library [<cctype>](cctype.syn#header:%3ccctype%3e "28.7.1Header <cctype> synopsis[cctype.syn]") features[.](#1.sentence-1)
istream members are required to use ctype<> for character classing during input parsing[.](#1.sentence-2)
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L1400)
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 ctype<char> and ctype<wchar_t>,
implement character classing appropriate
to the implementation's native character set[.](#2.sentence-1)

View File

@@ -0,0 +1,95 @@
[locale.ctype.members]
# 28 Text processing library [[text]](./#text)
## 28.3 Localization library [[localization]](localization#locale.ctype.members)
### 28.3.4 Standard locale categories [[locale.categories]](locale.categories#locale.ctype.members)
#### 28.3.4.2 The ctype category [[category.ctype]](category.ctype#locale.ctype.members)
#### 28.3.4.2.2 Class template ctype [[locale.ctype]](locale.ctype#members)
#### 28.3.4.2.2.2 ctype members [locale.ctype.members]
[🔗](#lib:ctype,is)
`bool is(mask m, charT c) const;
const charT* is(const charT* low, const charT* high, mask* vec) const;
`
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L1416)
*Returns*: do_is(m, c) or do_is(low, high, vec)[.](#1.sentence-1)
[🔗](#lib:ctype,scan_is)
`const charT* scan_is(mask m, const charT* low, const charT* high) const;
`
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L1427)
*Returns*: do_scan_is(m, low, high)[.](#2.sentence-1)
[🔗](#lib:ctype,scan_not)
`const charT* scan_not(mask m, const charT* low, const charT* high) const;
`
[3](#3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L1438)
*Returns*: do_scan_not(m, low, high)[.](#3.sentence-1)
[🔗](#lib:ctype,toupper)
`charT toupper(charT c) const;
const charT* toupper(charT* low, const charT* high) const;
`
[4](#4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L1450)
*Returns*: do_toupper(c) or do_toupper(low, high)[.](#4.sentence-1)
[🔗](#lib:ctype,tolower)
`charT tolower(charT c) const;
const charT* tolower(charT* low, const charT* high) const;
`
[5](#5)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L1462)
*Returns*: do_tolower(c) or do_tolower(low, high)[.](#5.sentence-1)
[🔗](#lib:ctype,widen)
`charT widen(char c) const;
const char* widen(const char* low, const char* high, charT* to) const;
`
[6](#6)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L1474)
*Returns*: do_widen(c) or do_widen(low, high, to)[.](#6.sentence-1)
[🔗](#lib:ctype,narrow)
`char narrow(charT c, char dfault) const;
const charT* narrow(const charT* low, const charT* high, char dfault, char* to) const;
`
[7](#7)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L1486)
*Returns*: do_narrow(c, dfault) or do_narrow(low, high, dfault, to)[.](#7.sentence-1)

View File

@@ -0,0 +1,214 @@
[locale.ctype.virtuals]
# 28 Text processing library [[text]](./#text)
## 28.3 Localization library [[localization]](localization#locale.ctype.virtuals)
### 28.3.4 Standard locale categories [[locale.categories]](locale.categories#locale.ctype.virtuals)
#### 28.3.4.2 The ctype category [[category.ctype]](category.ctype#locale.ctype.virtuals)
#### 28.3.4.2.2 Class template ctype [[locale.ctype]](locale.ctype#virtuals)
#### 28.3.4.2.2.3 ctype virtual functions [locale.ctype.virtuals]
[🔗](#lib:ctype,do_is)
`bool do_is(mask m, charT c) const;
const charT* do_is(const charT* low, const charT* high, mask* vec) const;
`
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L1500)
*Effects*: Classifies a character or sequence of characters[.](#1.sentence-1)
For each argument character,
identifies a value M of type ctype_base::mask[.](#1.sentence-2)
The second form identifies a value M of type ctype_base::mask for each *p where (low <= p && p < high),
and places it into vec[p - low][.](#1.sentence-3)
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L1509)
*Returns*: The first form returns the result of the expression (M & m) != 0;
i.e., true if the character has the characteristics specified[.](#2.sentence-1)
The second form returns high[.](#2.sentence-2)
[🔗](#lib:ctype_base,do_scan_is)
`const charT* do_scan_is(mask m, const charT* low, const charT* high) const;
`
[3](#3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L1522)
*Effects*: Locates a character in a buffer that conforms to a classification m[.](#3.sentence-1)
[4](#4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L1526)
*Returns*: The smallest pointer p in the range [low, high)
such that is(m, *p) would return true;
otherwise, returns high[.](#4.sentence-1)
[🔗](#lib:ctype,do_scan_not)
`const charT* do_scan_not(mask m, const charT* low, const charT* high) const;
`
[5](#5)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L1539)
*Effects*: Locates a character in a buffer that fails to conform to a classificationm[.](#5.sentence-1)
[6](#6)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L1544)
*Returns*: The smallest pointer p, if any, in the range [low, high)
such that is(m, *p) would return false;
otherwise, returns high[.](#6.sentence-1)
[🔗](#lib:ctype,do_toupper)
`charT do_toupper(charT c) const;
const charT* do_toupper(charT* low, const charT* high) const;
`
[7](#7)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L1558)
*Effects*: Converts a character or characters to upper case[.](#7.sentence-1)
The second form replaces
each character *p in the range [low, high)
for which a corresponding upper-case character exists,
with that character[.](#7.sentence-2)
[8](#8)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L1566)
*Returns*: The first form returns
the corresponding upper-case character if it is known to exist, or
its argument if not[.](#8.sentence-1)
The second form returns high[.](#8.sentence-2)
[🔗](#lib:ctype,do_tolower)
`charT do_tolower(charT c) const;
const charT* do_tolower(charT* low, const charT* high) const;
`
[9](#9)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L1581)
*Effects*: Converts a character or characters to lower case[.](#9.sentence-1)
The second form replaces
each character *p in the range [low, high)
and for which a corresponding lower-case character exists,
with that character[.](#9.sentence-2)
[10](#10)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L1589)
*Returns*: The first form returns
the corresponding lower-case character if it is known to exist, or
its argument if not[.](#10.sentence-1)
The second form returns high[.](#10.sentence-2)
[🔗](#lib:ctype,do_widen)
`charT do_widen(char c) const;
const char* do_widen(const char* low, const char* high, charT* dest) const;
`
[11](#11)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L1604)
*Effects*: Applies the simplest reasonable transformation
from a char value or sequence of char values
to the corresponding charT value or values[.](#11.sentence-1)[217](#footnote-217 "The parameter c of do_­widen is intended to accept values derived from character-literals for conversion to the locale's encoding.")
The only characters for which unique transformations are required
are those in the basic character set ([[lex.charset]](lex.charset "5.3.1Character sets"))[.](#11.sentence-2)
For any named ctype category with
a ctype<char> facet ctc and
valid ctype_base::mask value M,(ctc.is(M, c) || !is(M, do_widen(c)) ) is true[.](#11.sentence-3)[218](#footnote-218 "In other words, the transformed character is not a member of any character classification that c is not also a member of.")
The second form transforms
each character *p in the range [low, high),
placing the result in dest[p - low][.](#11.sentence-4)
[12](#12)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L1631)
*Returns*: The first form returns the transformed value[.](#12.sentence-1)
The second form returns high[.](#12.sentence-2)
[🔗](#lib:ctype,do_narrow)
`char do_narrow(charT c, char dfault) const;
const charT* do_narrow(const charT* low, const charT* high, char dfault, char* dest) const;
`
[13](#13)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L1644)
*Effects*: Applies the simplest reasonable transformation
from a charT value or sequence of charT values
to the corresponding char value or values[.](#13.sentence-1)
For any character c in the basic character set ([[lex.charset]](lex.charset "5.3.1Character sets"))
the transformation is such thatdo_widen(do_narrow(c, 0)) == c
For any named ctype category with
a ctype<char> facet ctc however, andctype_base::mask value M,(is(M, c) || !ctc.is(M, do_narrow(c, dfault)) ) is true (unless do_narrow returns dfault)[.](#13.sentence-3)
In addition, for any digit character c,
the expression (do_narrow(c, dfault) - '0') evaluates to the digit value of the character[.](#13.sentence-4)
The second form transforms
each character *p in the range [low, high),
placing the result
(or dfault if no simple transformation is readily available)
in dest[p - low][.](#13.sentence-5)
[14](#14)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L1672)
*Returns*: The first form returns the transformed value;
or dfault if no mapping is readily available[.](#14.sentence-1)
The second form returns high[.](#14.sentence-2)
[217)](#footnote-217)[217)](#footnoteref-217)
The parameter c of do_widen is intended to
accept values derived from [*character-literal*](lex.ccon#nt:character-literal "5.13.3Character literals[lex.ccon]")*s* for conversion to the locale's encoding[.](#footnote-217.sentence-1)
[218)](#footnote-218)[218)](#footnoteref-218)
In other words, the transformed character is not
a member of any character classification
that c is not also a member of[.](#footnote-218.sentence-1)

98
cppdraft/locale/facet.md Normal file
View File

@@ -0,0 +1,98 @@
[locale.facet]
# 28 Text processing library [[text]](./#text)
## 28.3 Localization library [[localization]](localization#locale.facet)
### 28.3.3 Locales [[locales]](locales#locale.facet)
#### 28.3.3.1 Class locale [[locale]](locale#facet)
#### 28.3.3.1.2 Types [[locale.types]](locale.types#locale.facet)
#### 28.3.3.1.2.2 Class locale::facet [locale.facet]
[🔗](#lib:locale,facet)
namespace std {class locale::facet {protected:explicit facet(size_t refs = 0); virtual ~facet();
facet(const facet&) = delete; void operator=(const facet&) = delete; };}
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L766)
Class facet is the base class for locale feature sets[.](#1.sentence-1)
A class is a [*facet*](#def:facet "28.3.3.1.2.2Class locale::facet[locale.facet]") if it is publicly derived from another facet, or
if it is a class derived from locale::facet and
contains a publicly accessible declaration as follows:[215](#footnote-215 "This is a complete list of requirements; there are no other requirements. Thus, a facet class need not have a public copy constructor, assignment, default constructor, destructor, etc.")static ::std::locale::id id;
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L781)
Template parameters in this Clause
which are required to be facets
are those named Facet in declarations[.](#2.sentence-1)
A program that passes
a type that is *not* a facet, or
a type that refers to a volatile-qualified facet,
as an (explicit or deduced) template parameter to
a locale function expecting a facet,
is ill-formed[.](#2.sentence-2)
A const-qualified facet is a valid template argument to
any locale function that expects a Facet template parameter[.](#2.sentence-3)
[3](#3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L794)
The refs argument to the constructor is used for lifetime management[.](#3.sentence-1)
For refs == 0,
the implementation performs delete static_cast<locale::facet*>(f) (where f is a pointer to the facet)
when the last locale object containing the facet is destroyed;
for refs == 1, the implementation never destroys the facet[.](#3.sentence-2)
[4](#4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L802)
Constructors of all facets defined in this Clause
take such an argument and pass it along to
their facet base class constructor[.](#4.sentence-1)
All one-argument constructors defined in this Clause are explicit,
preventing their participation in implicit conversions[.](#4.sentence-2)
[5](#5)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L809)
For some standard facets a standard “…_byname” class,
derived from it, implements the virtual function semantics
equivalent to that facet of the locale
constructed by locale(const char*) with the same name[.](#5.sentence-1)
Each such facet provides a constructor that takes
a const char* argument, which names the locale, and
a refs argument, which is passed to the base class constructor[.](#5.sentence-2)
Each such facet also provides a constructor that takes
a string argument str and
a refs argument,
which has the same effect as calling the first constructor
with the two arguments str.c_str() and refs[.](#5.sentence-3)
If there is no “…_byname” version of a facet,
the base class implements named locale semantics itself
by reference to other facets[.](#5.sentence-4)
[215)](#footnote-215)[215)](#footnoteref-215)
This is a complete list of requirements; there are no other requirements[.](#footnote-215.sentence-1)
Thus, a facet class need not have a public
copy constructor, assignment, default constructor, destructor, etc[.](#footnote-215.sentence-2)

142
cppdraft/locale/general.md Normal file
View File

@@ -0,0 +1,142 @@
[locale.general]
# 28 Text processing library [[text]](./#text)
## 28.3 Localization library [[localization]](localization#locale.general)
### 28.3.3 Locales [[locales]](locales#locale.general)
#### 28.3.3.1 Class locale [[locale]](locale#general)
#### 28.3.3.1.1 General [locale.general]
namespace std {class locale {public:// [[locale.types]](locale.types "28.3.3.1.2Types"), types// [[locale.facet]](locale.facet "28.3.3.1.2.2Class locale::facet"), class locale::facetclass facet; // [[locale.id]](locale.id "28.3.3.1.2.3Class locale::id"), class locale::idclass id; // [[locale.category]](locale.category "28.3.3.1.2.1Type locale::category"), type locale::categoryusing category = int; static const category // values assigned here are for exposition only none = 0,
collate = 0x010, ctype = 0x020,
monetary = 0x040, numeric = 0x080,
time = 0x100, messages = 0x200,
all = collate | ctype | monetary | numeric | time | messages; // [[locale.cons]](locale.cons "28.3.3.1.3Constructors and destructor"), construct/copy/destroy locale() noexcept;
locale(const locale& other) noexcept; explicit locale(const char* std_name); explicit locale(const string& std_name);
locale(const locale& other, const char* std_name, category);
locale(const locale& other, const string& std_name, category); template<class Facet> locale(const locale& other, Facet* f);
locale(const locale& other, const locale& one, category); ~locale(); // not virtualconst locale& operator=(const locale& other) noexcept; // [[locale.members]](locale.members "28.3.3.1.4Members"), locale operationstemplate<class Facet> locale combine(const locale& other) const;
string name() const;
text_encoding encoding() const; bool operator==(const locale& other) const; template<class charT, class traits, class Allocator>bool operator()(const basic_string<charT, traits, Allocator>& s1, const basic_string<charT, traits, Allocator>& s2) const; // [[locale.statics]](locale.statics "28.3.3.1.6Static members"), global locale objectsstatic locale global(const locale&); static const locale& classic(); };}
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L520)
Class locale implements a type-safe polymorphic set of facets,
indexed by facet *type*[.](#1.sentence-1)
In other words, a facet has a dual role:
in one sense, it's just a class interface;
at the same time, it's an index into a locale's set of facets[.](#1.sentence-2)
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L527)
Access to the facets of a locale is via two function templates,use_facet<> and has_facet<>[.](#2.sentence-1)
[3](#3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L531)
[*Example [1](#example-1)*:
An iostream operator<< can be implemented as:[214](#footnote-214 "Note that in the call to put, the stream is implicitly converted to an ostreambuf_­iterator<charT, traits>.")
template<class charT, class traits> basic_ostream<charT, traits>&operator<< (basic_ostream<charT, traits>& s, Date d) {typename basic_ostream<charT, traits>::sentry cerberos(s); if (cerberos) { tm tmbuf; d.extract(tmbuf); bool failed = use_facet<time_put<charT, ostreambuf_iterator<charT, traits>>>( s.getloc()).put(s, s, s.fill(), &tmbuf, 'x').failed(); if (failed) s.setstate(s.badbit); // can throw}return s;} — *end example*]
[4](#4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L558)
In the call to use_facet<Facet>(loc),
the type argument chooses a facet,
making available all members of the named type[.](#4.sentence-1)
If Facet is not present in a locale,
it throws the standard exception bad_cast[.](#4.sentence-2)
A C++ program can check if a locale implements a particular facet
with the function template has_facet<Facet>()[.](#4.sentence-3)
User-defined facets may be installed in a locale, and
used identically as may standard facets[.](#4.sentence-4)
[5](#5)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L569)
[*Note [1](#note-1)*:
All locale semantics are accessed viause_facet<> and has_facet<>,
except that:
- [(5.1)](#5.1)
A member operator templateoperator()(const basic_string<C, T, A>&, const basic_string<C, T, A>&) is provided so that a locale can be used as a predicate argument to
the standard collections, to collate strings.
- [(5.2)](#5.2)
Convenient global interfaces are provided for
traditional ctype functions such asisdigit() and isspace(),
so that given a locale object loc a C++ program can call isspace(c, loc). (This eases upgrading existing extractors ([[istream.formatted]](istream.formatted "31.7.5.3Formatted input functions"))[.](#5.2.sentence-2))
— *end note*]
[6](#6)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L593)
Once a facet reference is obtained from a locale object
by calling use_facet<>,
that reference remains usable,
and the results from member functions of it may be cached and re-used,
as long as some locale object refers to that facet[.](#6.sentence-1)
[7](#7)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L600)
In successive calls to a locale facet member function
on a facet object installed in the same locale,
the returned result shall be identical[.](#7.sentence-1)
[8](#8)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L605)
A locale constructed
from a name string (such as "POSIX"), or
from parts of two named locales, has a name;
all others do not[.](#8.sentence-1)
Named locales may be compared for equality;
an unnamed locale is equal only to (copies of) itself[.](#8.sentence-2)
For an unnamed locale, locale::name() returns the string "*"[.](#8.sentence-3)
[9](#9)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L614)
Whether there is
one global locale object for the entire program or
one global locale object per thread
is implementation-defined[.](#9.sentence-1)
Implementations should provide one global locale object per thread[.](#9.sentence-2)
If there is a single global locale object for the entire program,
implementations are not required to
avoid data races on it ([[res.on.data.races]](res.on.data.races "16.4.6.10Data race avoidance"))[.](#9.sentence-3)
[214)](#footnote-214)[214)](#footnoteref-214)
Note that in the call to put,
the stream is implicitly converted
to an ostreambuf_iterator<charT, traits>[.](#footnote-214.sentence-1)

View File

@@ -0,0 +1,52 @@
[locale.global.templates]
# 28 Text processing library [[text]](./#text)
## 28.3 Localization library [[localization]](localization#locale.global.templates)
### 28.3.3 Locales [[locales]](locales#locale.global.templates)
#### 28.3.3.2 locale globals [locale.global.templates]
[🔗](#lib:locale,use_facet)
`template<class Facet> const Facet& use_facet(const locale& loc);
`
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L1177)
*Mandates*: Facet is a facet class
whose definition contains the public static member id as defined in [[locale.facet]](locale.facet "28.3.3.1.2.2Class locale::facet")[.](#1.sentence-1)
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L1183)
*Returns*: A reference to the corresponding facet of loc, if present[.](#2.sentence-1)
[3](#3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L1187)
*Throws*: bad_cast if has_facet<Facet>(loc) is false[.](#3.sentence-1)
[4](#4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L1191)
*Remarks*: The reference returned remains valid
at least as long as any copy of loc exists[.](#4.sentence-1)
[🔗](#lib:locale,has_facet)
`template<class Facet> bool has_facet(const locale& loc) noexcept;
`
[5](#5)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L1203)
*Returns*: true if the facet requested is present in loc;
otherwise false[.](#5.sentence-1)

44
cppdraft/locale/id.md Normal file
View File

@@ -0,0 +1,44 @@
[locale.id]
# 28 Text processing library [[text]](./#text)
## 28.3 Localization library [[localization]](localization#locale.id)
### 28.3.3 Locales [[locales]](locales#locale.id)
#### 28.3.3.1 Class locale [[locale]](locale#id)
#### 28.3.3.1.2 Types [[locale.types]](locale.types#locale.id)
#### 28.3.3.1.2.3 Class locale::id [locale.id]
[🔗](#lib:locale,id)
namespace std {class locale::id {public: id(); void operator=(const id&) = delete;
id(const id&) = delete; };}
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L840)
The class locale::id provides
identification of a locale facet interface,
used as an index for lookup and to encapsulate initialization[.](#1.sentence-1)
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L845)
[*Note [1](#note-1)*:
Because facets are used by iostreams,
potentially while static constructors are running,
their initialization cannot depend on programmed static initialization[.](#2.sentence-1)
One initialization strategy is for locale to initialize each facet's id member
the first time an instance of the facet is installed into a locale[.](#2.sentence-2)
This depends only on static storage being zero
before constructors run ([[basic.start.static]](basic.start.static "6.10.3.2Static initialization"))[.](#2.sentence-3)
— *end note*]

View File

@@ -0,0 +1,71 @@
[locale.members]
# 28 Text processing library [[text]](./#text)
## 28.3 Localization library [[localization]](localization#locale.members)
### 28.3.3 Locales [[locales]](locales#locale.members)
#### 28.3.3.1 Class locale [[locale]](locale#members)
#### 28.3.3.1.4 Members [locale.members]
[🔗](#lib:locale,combine)
`template<class Facet> locale combine(const locale& other) const;
`
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L1015)
*Effects*: Constructs a locale incorporating all facets from *this except for that one facet of other that is identified by Facet[.](#1.sentence-1)
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L1020)
*Returns*: The newly created locale[.](#2.sentence-1)
[3](#3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L1024)
*Throws*: runtime_error if has_facet<Facet>(other) is false[.](#3.sentence-1)
[4](#4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L1028)
*Remarks*: The resulting locale has no name[.](#4.sentence-1)
[🔗](#lib:locale,name)
`string name() const;
`
[5](#5)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L1039)
*Returns*: The name of *this, if it has one;
otherwise, the string "*"[.](#5.sentence-1)
[🔗](#lib:locale,encoding)
`text_encoding encoding() const;
`
[6](#6)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L1051)
*Mandates*: CHAR_BIT == 8 is true[.](#6.sentence-1)
[7](#7)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L1055)
*Returns*: A text_encoding object representing
the implementation-defined encoding scheme
associated with the locale *this[.](#7.sentence-1)

135
cppdraft/locale/messages.md Normal file
View File

@@ -0,0 +1,135 @@
[locale.messages]
# 28 Text processing library [[text]](./#text)
## 28.3 Localization library [[localization]](localization#locale.messages)
### 28.3.4 Standard locale categories [[locale.categories]](locale.categories#locale.messages)
#### 28.3.4.8 The message retrieval category [[category.messages]](category.messages#locale.messages)
#### 28.3.4.8.2 Class template messages [locale.messages]
#### [28.3.4.8.2.1](#general) General [[locale.messages.general]](locale.messages.general)
[🔗](#lib:messages)
namespace std {class messages_base {public:using catalog = *unspecified signed integer type*; }; template<class charT>class messages : public locale::facet, public messages_base {public:using char_type = charT; using string_type = basic_string<charT>; explicit messages(size_t refs = 0);
catalog open(const string& fn, const locale&) const;
string_type get(catalog c, int set, int msgid, const string_type& dfault) const; void close(catalog c) const; static locale::id id; protected:~messages(); virtual catalog do_open(const string&, const locale&) const; virtual string_type do_get(catalog, int set, int msgid, const string_type& dfault) const; virtual void do_close(catalog) const; };}
[1](#general-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L4771)
Values of type messages_base::catalog usable as arguments to members get and close can be obtained only by calling member open[.](#general-1.sentence-1)
#### [28.3.4.8.2.2](#members) Members [[locale.messages.members]](locale.messages.members)
[🔗](#lib:messages,open)
`catalog open(const string& name, const locale& loc) const;
`
[1](#members-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L4784)
*Returns*: do_open(name, loc)[.](#members-1.sentence-1)
[🔗](#lib:messages,get)
`string_type get(catalog cat, int set, int msgid, const string_type& dfault) const;
`
[2](#members-2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L4795)
*Returns*: do_get(cat, set, msgid, dfault)[.](#members-2.sentence-1)
[🔗](#lib:messages,close)
`void close(catalog cat) const;
`
[3](#members-3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L4806)
*Effects*: Calls do_close(cat)[.](#members-3.sentence-1)
#### [28.3.4.8.2.3](#virtuals) Virtual functions [[locale.messages.virtuals]](locale.messages.virtuals)
[🔗](#lib:messages,do_open)
`catalog do_open(const string& name, const locale& loc) const;
`
[1](#virtuals-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L4819)
*Returns*: A value that may be passed to get() to retrieve a message from the message catalog
identified by the string name according to an implementation-defined mapping[.](#virtuals-1.sentence-1)
The result can be used until it is passed to close()[.](#virtuals-1.sentence-2)
[2](#virtuals-2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L4828)
Returns a value less than 0 if no such catalog can be opened[.](#virtuals-2.sentence-1)
[3](#virtuals-3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L4831)
*Remarks*: The locale argument loc is used for
character set code conversion when retrieving messages, if needed[.](#virtuals-3.sentence-1)
[🔗](#lib:messages,do_get)
`string_type do_get(catalog cat, int set, int msgid, const string_type& dfault) const;
`
[4](#virtuals-4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L4843)
*Preconditions*: cat is a catalog obtained from open() and not yet closed[.](#virtuals-4.sentence-1)
[5](#virtuals-5)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L4847)
*Returns*: A message identified by
arguments set, msgid, and dfault,
according to
an implementation-defined mapping[.](#virtuals-5.sentence-1)
If no such message can be found, returns dfault[.](#virtuals-5.sentence-2)
[🔗](#lib:message,do_close)
`void do_close(catalog cat) const;
`
[6](#virtuals-6)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L4862)
*Preconditions*: cat is a catalog obtained from open() and not yet closed[.](#virtuals-6.sentence-1)
[7](#virtuals-7)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L4866)
*Effects*: Releases unspecified resources associated with cat[.](#virtuals-7.sentence-1)
[8](#virtuals-8)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L4870)
*Remarks*: The limit on such resources, if any, isimplementation-defined[.](#virtuals-8.sentence-1)

View File

@@ -0,0 +1,15 @@
[locale.messages.byname]
# 28 Text processing library [[text]](./#text)
## 28.3 Localization library [[localization]](localization#locale.messages.byname)
### 28.3.4 Standard locale categories [[locale.categories]](locale.categories#locale.messages.byname)
#### 28.3.4.8 The message retrieval category [[category.messages]](category.messages#locale.messages.byname)
#### 28.3.4.8.3 Class template messages_byname [locale.messages.byname]
[🔗](#lib:messages_byname)
namespace std {template<class charT>class messages_byname : public messages<charT> {public:using catalog = messages_base::catalog; using string_type = basic_string<charT>; explicit messages_byname(const char*, size_t refs = 0); explicit messages_byname(const string&, size_t refs = 0); protected:~messages_byname(); };}

View File

@@ -0,0 +1,26 @@
[locale.messages.general]
# 28 Text processing library [[text]](./#text)
## 28.3 Localization library [[localization]](localization#locale.messages.general)
### 28.3.4 Standard locale categories [[locale.categories]](locale.categories#locale.messages.general)
#### 28.3.4.8 The message retrieval category [[category.messages]](category.messages#locale.messages.general)
#### 28.3.4.8.2 Class template messages [[locale.messages]](locale.messages#general)
#### 28.3.4.8.2.1 General [locale.messages.general]
[🔗](#lib:messages)
namespace std {class messages_base {public:using catalog = *unspecified signed integer type*; }; template<class charT>class messages : public locale::facet, public messages_base {public:using char_type = charT; using string_type = basic_string<charT>; explicit messages(size_t refs = 0);
catalog open(const string& fn, const locale&) const;
string_type get(catalog c, int set, int msgid, const string_type& dfault) const; void close(catalog c) const; static locale::id id; protected:~messages(); virtual catalog do_open(const string&, const locale&) const; virtual string_type do_get(catalog, int set, int msgid, const string_type& dfault) const; virtual void do_close(catalog) const; };}
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L4771)
Values of type messages_base::catalog usable as arguments to members get and close can be obtained only by calling member open[.](#1.sentence-1)

View File

@@ -0,0 +1,46 @@
[locale.messages.members]
# 28 Text processing library [[text]](./#text)
## 28.3 Localization library [[localization]](localization#locale.messages.members)
### 28.3.4 Standard locale categories [[locale.categories]](locale.categories#locale.messages.members)
#### 28.3.4.8 The message retrieval category [[category.messages]](category.messages#locale.messages.members)
#### 28.3.4.8.2 Class template messages [[locale.messages]](locale.messages#members)
#### 28.3.4.8.2.2 Members [locale.messages.members]
[🔗](#lib:messages,open)
`catalog open(const string& name, const locale& loc) const;
`
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L4784)
*Returns*: do_open(name, loc)[.](#1.sentence-1)
[🔗](#lib:messages,get)
`string_type get(catalog cat, int set, int msgid, const string_type& dfault) const;
`
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L4795)
*Returns*: do_get(cat, set, msgid, dfault)[.](#2.sentence-1)
[🔗](#lib:messages,close)
`void close(catalog cat) const;
`
[3](#3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L4806)
*Effects*: Calls do_close(cat)[.](#3.sentence-1)

View File

@@ -0,0 +1,85 @@
[locale.messages.virtuals]
# 28 Text processing library [[text]](./#text)
## 28.3 Localization library [[localization]](localization#locale.messages.virtuals)
### 28.3.4 Standard locale categories [[locale.categories]](locale.categories#locale.messages.virtuals)
#### 28.3.4.8 The message retrieval category [[category.messages]](category.messages#locale.messages.virtuals)
#### 28.3.4.8.2 Class template messages [[locale.messages]](locale.messages#virtuals)
#### 28.3.4.8.2.3 Virtual functions [locale.messages.virtuals]
[🔗](#lib:messages,do_open)
`catalog do_open(const string& name, const locale& loc) const;
`
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L4819)
*Returns*: A value that may be passed to get() to retrieve a message from the message catalog
identified by the string name according to an implementation-defined mapping[.](#1.sentence-1)
The result can be used until it is passed to close()[.](#1.sentence-2)
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L4828)
Returns a value less than 0 if no such catalog can be opened[.](#2.sentence-1)
[3](#3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L4831)
*Remarks*: The locale argument loc is used for
character set code conversion when retrieving messages, if needed[.](#3.sentence-1)
[🔗](#lib:messages,do_get)
`string_type do_get(catalog cat, int set, int msgid, const string_type& dfault) const;
`
[4](#4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L4843)
*Preconditions*: cat is a catalog obtained from open() and not yet closed[.](#4.sentence-1)
[5](#5)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L4847)
*Returns*: A message identified by
arguments set, msgid, and dfault,
according to
an implementation-defined mapping[.](#5.sentence-1)
If no such message can be found, returns dfault[.](#5.sentence-2)
[🔗](#lib:message,do_close)
`void do_close(catalog cat) const;
`
[6](#6)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L4862)
*Preconditions*: cat is a catalog obtained from open() and not yet closed[.](#6.sentence-1)
[7](#7)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L4866)
*Effects*: Releases unspecified resources associated with cat[.](#7.sentence-1)
[8](#8)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L4870)
*Remarks*: The limit on such resources, if any, isimplementation-defined[.](#8.sentence-1)

View File

@@ -0,0 +1,171 @@
[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)

View File

@@ -0,0 +1,25 @@
[locale.money.get.general]
# 28 Text processing library [[text]](./#text)
## 28.3 Localization library [[localization]](localization#locale.money.get.general)
### 28.3.4 Standard locale categories [[locale.categories]](locale.categories#locale.money.get.general)
#### 28.3.4.7 The monetary category [[category.monetary]](category.monetary#locale.money.get.general)
#### 28.3.4.7.2 Class template money_get [[locale.money.get]](locale.money.get#general)
#### 28.3.4.7.2.1 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; };}

View File

@@ -0,0 +1,27 @@
[locale.money.get.members]
# 28 Text processing library [[text]](./#text)
## 28.3 Localization library [[localization]](localization#locale.money.get.members)
### 28.3.4 Standard locale categories [[locale.categories]](locale.categories#locale.money.get.members)
#### 28.3.4.7 The monetary category [[category.monetary]](category.monetary#locale.money.get.members)
#### 28.3.4.7.2 Class template money_get [[locale.money.get]](locale.money.get#members)
#### 28.3.4.7.2.2 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](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L4175)
*Returns*: do_get(s, end, intl, f, err, quant)[.](#1.sentence-1)

View File

@@ -0,0 +1,141 @@
[locale.money.get.virtuals]
# 28 Text processing library [[text]](./#text)
## 28.3 Localization library [[localization]](localization#locale.money.get.virtuals)
### 28.3.4 Standard locale categories [[locale.categories]](locale.categories#locale.money.get.virtuals)
#### 28.3.4.7 The monetary category [[category.monetary]](category.monetary#locale.money.get.virtuals)
#### 28.3.4.7.2 Class template money_get [[locale.money.get]](locale.money.get#virtuals)
#### 28.3.4.7.2.3 Virtual functions [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](#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()[.](#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[.](#1.sentence-2)
Uses the pattern returned by mp.neg_format() to parse all values[.](#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[.](#1.sentence-4)
[*Example [1](#example-1)*:
The sequence $1,056.23 in a common United States locale would yield,
for units, 105623, or,
for digits, "105623"[.](#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[.](#1.sentence-6)
Otherwise, thousands separators are optional;
if present, they are checked for correct placement only after
all format components have been read[.](#1.sentence-7)
[2](#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[.](#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[.](#2.sentence-2)
Where money_base::none appears
in any of the initial elements of the format pattern,
whitespace is allowed but not required[.](#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[.](#2.sentence-4)
[3](#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[.](#3.sentence-1)
[*Example [2](#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[.](#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[.](#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[.](#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[.](#3.sentence-5)
[4](#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[.](#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](#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[.](#5.sentence-1)
[229)](#footnote-229)[229)](#footnoteref-229)
The semantics here are different from ct.narrow[.](#footnote-229.sentence-1)

View File

@@ -0,0 +1,113 @@
[locale.money.put]
# 28 Text processing library [[text]](./#text)
## 28.3 Localization library [[localization]](localization#locale.money.put)
### 28.3.4 Standard locale categories [[locale.categories]](locale.categories#locale.money.put)
#### 28.3.4.7 The monetary category [[category.monetary]](category.monetary#locale.money.put)
#### 28.3.4.7.3 Class template money_put [locale.money.put]
#### [28.3.4.7.3.1](#general) General [[locale.money.put.general]](locale.money.put.general)
[🔗](#lib:money_put)
namespace std {template<class charT, class OutputIterator = ostreambuf_iterator<charT>>class money_put : public locale::facet {public:using char_type = charT; using iter_type = OutputIterator; using string_type = basic_string<charT>; explicit money_put(size_t refs = 0);
iter_type put(iter_type s, bool intl, ios_base& f,
char_type fill, long double units) const;
iter_type put(iter_type s, bool intl, ios_base& f,
char_type fill, const string_type& digits) const; static locale::id id; protected:~money_put(); virtual iter_type do_put(iter_type, bool, ios_base&, char_type fill, long double units) const; virtual iter_type do_put(iter_type, bool, ios_base&, char_type fill, const string_type& digits) const; };}
#### [28.3.4.7.3.2](#members) Members [[locale.money.put.members]](locale.money.put.members)
[🔗](#lib:money_put,put)
`iter_type put(iter_type s, bool intl, ios_base& f, char_type fill, long double quant) const;
iter_type put(iter_type s, bool intl, ios_base& f, char_type fill, const string_type& quant) const;
`
[1](#members-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L4340)
*Returns*: do_put(s, intl, f, fill, quant)[.](#members-1.sentence-1)
#### [28.3.4.7.3.3](#virtuals) Virtual functions [[locale.money.put.virtuals]](locale.money.put.virtuals)
[🔗](#lib:money_put,do_put)
`iter_type do_put(iter_type s, bool intl, ios_base& str,
char_type fill, long double units) const;
iter_type do_put(iter_type s, bool intl, ios_base& str,
char_type fill, const string_type& digits) const;
`
[1](#virtuals-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L4356)
*Effects*: Writes characters to s 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(),
and str.flags()[.](#virtuals-1.sentence-1)
The argument units is transformed into
a sequence of wide characters as if byct.widen(buf1, buf1 + sprintf(buf1, "%.0Lf", units), buf2) for character buffers buf1 and buf2[.](#virtuals-1.sentence-2)
If the first character in digits or buf2 is equal to ct.widen('-'),
then the pattern used for formatting is the result of mp.neg_format();
otherwise the pattern is the result of mp.pos_format()[.](#virtuals-1.sentence-3)
Digit characters are written,
interspersed with any thousands separators and decimal point
specified by the format,
in the order they appear (after the optional leading minus sign) indigits or buf2[.](#virtuals-1.sentence-4)
In digits,
only the optional leading minus sign and
the immediately subsequent digit characters
(as classified according to ct)
are used;
any trailing characters
(including digits appearing after a non-digit character)
are ignored[.](#virtuals-1.sentence-5)
Calls str.width(0)[.](#virtuals-1.sentence-6)
[2](#virtuals-2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L4390)
*Returns*: An iterator pointing immediately after the last character produced[.](#virtuals-2.sentence-1)
[3](#virtuals-3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L4394)
*Remarks*: The currency symbol is generated
if and only if (str.flags() & str.showbase) is nonzero[.](#virtuals-3.sentence-1)
If the number of characters generated for the specified format
is less than the value returned by str.width() on entry to the function,
then copies of fill are inserted as necessary
to pad to the specified width[.](#virtuals-3.sentence-2)
For the value af equal to (str.flags() & str.adjustfield),
if (af == str.internal) is true,
the fill characters are placed
where none or space appears in the formatting pattern;
otherwise if (af == str.left) is true,
they are placed after the other characters;
otherwise, they are placed before the other characters[.](#virtuals-3.sentence-3)
[*Note [1](#virtuals-note-1)*:
It is possible, with some combinations of format patterns and flag values,
to produce output that cannot be parsed using num_get<>::get[.](#virtuals-3.sentence-4)
— *end note*]

View File

@@ -0,0 +1,22 @@
[locale.money.put.general]
# 28 Text processing library [[text]](./#text)
## 28.3 Localization library [[localization]](localization#locale.money.put.general)
### 28.3.4 Standard locale categories [[locale.categories]](locale.categories#locale.money.put.general)
#### 28.3.4.7 The monetary category [[category.monetary]](category.monetary#locale.money.put.general)
#### 28.3.4.7.3 Class template money_put [[locale.money.put]](locale.money.put#general)
#### 28.3.4.7.3.1 General [locale.money.put.general]
[🔗](#lib:money_put)
namespace std {template<class charT, class OutputIterator = ostreambuf_iterator<charT>>class money_put : public locale::facet {public:using char_type = charT; using iter_type = OutputIterator; using string_type = basic_string<charT>; explicit money_put(size_t refs = 0);
iter_type put(iter_type s, bool intl, ios_base& f,
char_type fill, long double units) const;
iter_type put(iter_type s, bool intl, ios_base& f,
char_type fill, const string_type& digits) const; static locale::id id; protected:~money_put(); virtual iter_type do_put(iter_type, bool, ios_base&, char_type fill, long double units) const; virtual iter_type do_put(iter_type, bool, ios_base&, char_type fill, const string_type& digits) const; };}

View File

@@ -0,0 +1,25 @@
[locale.money.put.members]
# 28 Text processing library [[text]](./#text)
## 28.3 Localization library [[localization]](localization#locale.money.put.members)
### 28.3.4 Standard locale categories [[locale.categories]](locale.categories#locale.money.put.members)
#### 28.3.4.7 The monetary category [[category.monetary]](category.monetary#locale.money.put.members)
#### 28.3.4.7.3 Class template money_put [[locale.money.put]](locale.money.put#members)
#### 28.3.4.7.3.2 Members [locale.money.put.members]
[🔗](#lib:money_put,put)
`iter_type put(iter_type s, bool intl, ios_base& f, char_type fill, long double quant) const;
iter_type put(iter_type s, bool intl, ios_base& f, char_type fill, const string_type& quant) const;
`
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L4340)
*Returns*: do_put(s, intl, f, fill, quant)[.](#1.sentence-1)

View File

@@ -0,0 +1,88 @@
[locale.money.put.virtuals]
# 28 Text processing library [[text]](./#text)
## 28.3 Localization library [[localization]](localization#locale.money.put.virtuals)
### 28.3.4 Standard locale categories [[locale.categories]](locale.categories#locale.money.put.virtuals)
#### 28.3.4.7 The monetary category [[category.monetary]](category.monetary#locale.money.put.virtuals)
#### 28.3.4.7.3 Class template money_put [[locale.money.put]](locale.money.put#virtuals)
#### 28.3.4.7.3.3 Virtual functions [locale.money.put.virtuals]
[🔗](#lib:money_put,do_put)
`iter_type do_put(iter_type s, bool intl, ios_base& str,
char_type fill, long double units) const;
iter_type do_put(iter_type s, bool intl, ios_base& str,
char_type fill, const string_type& digits) const;
`
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L4356)
*Effects*: Writes characters to s 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(),
and str.flags()[.](#1.sentence-1)
The argument units is transformed into
a sequence of wide characters as if byct.widen(buf1, buf1 + sprintf(buf1, "%.0Lf", units), buf2) for character buffers buf1 and buf2[.](#1.sentence-2)
If the first character in digits or buf2 is equal to ct.widen('-'),
then the pattern used for formatting is the result of mp.neg_format();
otherwise the pattern is the result of mp.pos_format()[.](#1.sentence-3)
Digit characters are written,
interspersed with any thousands separators and decimal point
specified by the format,
in the order they appear (after the optional leading minus sign) indigits or buf2[.](#1.sentence-4)
In digits,
only the optional leading minus sign and
the immediately subsequent digit characters
(as classified according to ct)
are used;
any trailing characters
(including digits appearing after a non-digit character)
are ignored[.](#1.sentence-5)
Calls str.width(0)[.](#1.sentence-6)
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L4390)
*Returns*: An iterator pointing immediately after the last character produced[.](#2.sentence-1)
[3](#3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L4394)
*Remarks*: The currency symbol is generated
if and only if (str.flags() & str.showbase) is nonzero[.](#3.sentence-1)
If the number of characters generated for the specified format
is less than the value returned by str.width() on entry to the function,
then copies of fill are inserted as necessary
to pad to the specified width[.](#3.sentence-2)
For the value af equal to (str.flags() & str.adjustfield),
if (af == str.internal) is true,
the fill characters are placed
where none or space appears in the formatting pattern;
otherwise if (af == str.left) is true,
they are placed after the other characters;
otherwise, they are placed before the other characters[.](#3.sentence-3)
[*Note [1](#note-1)*:
It is possible, with some combinations of format patterns and flag values,
to produce output that cannot be parsed using num_get<>::get[.](#3.sentence-4)
— *end note*]

View File

@@ -0,0 +1,282 @@
[locale.moneypunct]
# 28 Text processing library [[text]](./#text)
## 28.3 Localization library [[localization]](localization#locale.moneypunct)
### 28.3.4 Standard locale categories [[locale.categories]](locale.categories#locale.moneypunct)
#### 28.3.4.7 The monetary category [[category.monetary]](category.monetary#locale.moneypunct)
#### 28.3.4.7.4 Class template moneypunct [locale.moneypunct]
#### [28.3.4.7.4.1](#general) General [[locale.moneypunct.general]](locale.moneypunct.general)
[🔗](#lib:moneypunct)
namespace std {class money_base {public:enum part { none, space, symbol, sign, value }; struct pattern { char field[4]; }; }; template<class charT, bool International = false>class moneypunct : public locale::facet, public money_base {public:using char_type = charT; using string_type = basic_string<charT>; explicit moneypunct(size_t refs = 0);
charT decimal_point() const;
charT thousands_sep() const;
string grouping() const;
string_type curr_symbol() const;
string_type positive_sign() const;
string_type negative_sign() const; int frac_digits() const;
pattern pos_format() const;
pattern neg_format() const; static locale::id id; static const bool intl = International; protected:~moneypunct(); virtual charT do_decimal_point() const; virtual charT do_thousands_sep() const; virtual string do_grouping() const; virtual string_type do_curr_symbol() const; virtual string_type do_positive_sign() const; virtual string_type do_negative_sign() const; virtual int do_frac_digits() const; virtual pattern do_pos_format() const; virtual pattern do_neg_format() const; };}
[1](#general-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L4465)
The moneypunct<> facet defines monetary formatting parameters
used by money_get<> and money_put<>[.](#general-1.sentence-1)
A monetary format is a sequence of four components,
specified by a pattern value p,
such that the part value static_cast<part>(p.field[i]) determines the ith component of the format[.](#general-1.sentence-2)[230](#footnote-230 "An array of char, rather than an array of part, is specified for pattern::field purely for efficiency.")
In the field member of a pattern object,
each value symbol, sign, value, and
either space or none appears exactly once[.](#general-1.sentence-3)
The value none, if present, is not first;
the value space, if present, is neither first nor last[.](#general-1.sentence-4)
[2](#general-2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L4484)
Where none or space appears,
whitespace is permitted in the format,
except where none appears at the end,
in which case no whitespace is permitted[.](#general-2.sentence-1)
The value space indicates that
at least one space is required at that position[.](#general-2.sentence-2)
Where symbol appears,
the sequence of characters returned by curr_symbol() is permitted, and
can be required[.](#general-2.sentence-3)
Where sign appears,
the first (if any) of the sequence of characters returned bypositive_sign() or negative_sign() (respectively as the monetary value is non-negative or negative) is required[.](#general-2.sentence-4)
Any remaining characters of the sign sequence are required after
all other format components[.](#general-2.sentence-5)
Where value appears, the absolute numeric monetary value is required[.](#general-2.sentence-6)
[3](#general-3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L4502)
The format of the numeric monetary value is a decimal number:
value :
units fractionalopt
decimal-point digits
fractional :
decimal-point digitsopt
if frac_digits() returns a positive value, or
value :
units
otherwise[.](#general-3.sentence-1)
The symbol *decimal-point* indicates the character returned by decimal_point()[.](#general-3.sentence-2)
The other symbols are defined as follows:
units :
digits
digits thousands-sep units
digits :
adigit digitsopt
In the syntax specification,
the symbol *adigit* is any of the values ct.widen(c) for c in the range '0' through '9' (inclusive) andct is a reference of type const ctype<charT>& obtained as described in the definitions
of money_get<> and money_put<>[.](#general-3.sentence-4)
The symbol *thousands-sep* is the character returned by thousands_sep()[.](#general-3.sentence-5)
The space character used is the value ct.widen(' ')[.](#general-3.sentence-6)
Whitespace characters are those characters c for which ci.is(space, c) returns true[.](#general-3.sentence-7)
The number of digits required after the decimal point (if any)
is exactly the value returned by frac_digits()[.](#general-3.sentence-8)
[4](#general-4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L4548)
The placement of thousands-separator characters (if any)
is determined by the value returned by grouping(),
defined identically as the member numpunct<>::do_grouping()[.](#general-4.sentence-1)
[230)](#footnote-230)[230)](#footnoteref-230)
An array of char,
rather than an array of part,
is specified for pattern::field purely for efficiency[.](#footnote-230.sentence-1)
#### [28.3.4.7.4.2](#members) Members [[locale.moneypunct.members]](locale.moneypunct.members)
[🔗](#lib:moneypunct,decimal_point)
charT decimal_point() const;
charT thousands_sep() const;
string grouping() const;
string_type curr_symbol() const;
string_type positive_sign() const;
string_type negative_sign() const;int frac_digits() const;
pattern pos_format() const;
pattern neg_format() const;
[1](#members-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L4576)
Each of these functions *F* returns the result of calling the corresponding
virtual member functiondo_*F*()[.](#members-1.sentence-1)
#### [28.3.4.7.4.3](#virtuals) Virtual functions [[locale.moneypunct.virtuals]](locale.moneypunct.virtuals)
[🔗](#lib:moneypunct,do_decimal_point)
`charT do_decimal_point() const;
`
[1](#virtuals-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L4590)
*Returns*: The radix separator to use
in case do_frac_digits() is greater than zero[.](#virtuals-1.sentence-1)[231](#footnote-231 "In common U.S. locales this is '.'.")
[🔗](#lib:moneypunct,do_thousands_sep)
`charT do_thousands_sep() const;
`
[2](#virtuals-2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L4605)
*Returns*: The digit group separator to use
in case do_grouping() specifies a digit grouping pattern[.](#virtuals-2.sentence-1)[232](#footnote-232 "In common U.S. locales this is ','.")
[🔗](#lib:moneypunct,do_grouping)
`string do_grouping() const;
`
[3](#virtuals-3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L4620)
*Returns*: A pattern defined identically as, but not necessarily equal to,
the result of numpunct<charT>::do_grouping()[.](#virtuals-3.sentence-1)[233](#footnote-233 "To specify grouping by 3s, the value is &quot;\003&quot; not &quot;3&quot;.")
[🔗](#lib:moneypunct,do_curr_symbol)
`string_type do_curr_symbol() const;
`
[4](#virtuals-4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L4636)
*Returns*: A string to use as the currency identifier symbol[.](#virtuals-4.sentence-1)
[*Note [1](#virtuals-note-1)*:
For specializations where the second template parameter is true,
this is typically four characters long:
a three-letter code as specified by ISO 4217[[bib]](bibliography#bib:iso4217 "Bibliography") followed by a space[.](#virtuals-4.sentence-2)
— *end note*]
[🔗](#lib:moneypunct,do_positive_sign)
`string_type do_positive_sign() const;
string_type do_negative_sign() const;
`
[5](#virtuals-5)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L4655)
*Returns*: do_positive_sign() returns the string to use to indicate a positive monetary value;[234](#footnote-234 "This is usually the empty string.")do_negative_sign() returns the string to use to indicate a negative value[.](#virtuals-5.sentence-1)
[🔗](#lib:moneypunct,do_frac_digits)
`int do_frac_digits() const;
`
[6](#virtuals-6)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L4672)
*Returns*: The number of digits after the decimal radix separator, if any[.](#virtuals-6.sentence-1)[235](#footnote-235 "In common U.S.&nbsp;locales, this is 2.")
[🔗](#lib:moneypunct,do_pos_format)
`pattern do_pos_format() const;
pattern do_neg_format() const;
`
[7](#virtuals-7)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L4688)
*Returns*: The specializations required in Table [92](locale.category#tab:locale.spec "Table 92: Required specializations") ([[locale.category]](locale.category "28.3.3.1.2.1Type locale::category")), namely
- [(7.1)](#virtuals-7.1)
moneypunct<char>,
- [(7.2)](#virtuals-7.2)
moneypunct<wchar_t>,
- [(7.3)](#virtuals-7.3)
moneypunct<char, true>, and
- [(7.4)](#virtuals-7.4)
moneypunct<wchar_t, true>,
return an object of type pattern initialized to { symbol, sign, none, value }[.](#virtuals-7.sentence-1)[236](#footnote-236 "Note that the international symbol returned by do_­curr_­symbol() usually contains a space, itself; for example, &quot;USD &quot;.")
[231)](#footnote-231)[231)](#footnoteref-231)
In common U.S. locales this is '.'[.](#footnote-231.sentence-1)
[232)](#footnote-232)[232)](#footnoteref-232)
In common U.S. locales this is ','[.](#footnote-232.sentence-1)
[233)](#footnote-233)[233)](#footnoteref-233)
To specify grouping by 3s,
the value is "\003" *not* "3"[.](#footnote-233.sentence-1)
[234)](#footnote-234)[234)](#footnoteref-234)
This is usually the empty string[.](#footnote-234.sentence-1)
[235)](#footnote-235)[235)](#footnoteref-235)
In common U.S. locales, this is 2[.](#footnote-235.sentence-1)
[236)](#footnote-236)[236)](#footnoteref-236)
Note that the international symbol returned by do_curr_symbol() usually contains a space, itself;
for example, "USD "[.](#footnote-236.sentence-1)

View File

@@ -0,0 +1,15 @@
[locale.moneypunct.byname]
# 28 Text processing library [[text]](./#text)
## 28.3 Localization library [[localization]](localization#locale.moneypunct.byname)
### 28.3.4 Standard locale categories [[locale.categories]](locale.categories#locale.moneypunct.byname)
#### 28.3.4.7 The monetary category [[category.monetary]](category.monetary#locale.moneypunct.byname)
#### 28.3.4.7.5 Class template moneypunct_byname [locale.moneypunct.byname]
[🔗](#lib:moneypunct_byname)
namespace std {template<class charT, bool Intl = false>class moneypunct_byname : public moneypunct<charT, Intl> {public:using pattern = money_base::pattern; using string_type = basic_string<charT>; explicit moneypunct_byname(const char*, size_t refs = 0); explicit moneypunct_byname(const string&, size_t refs = 0); protected:~moneypunct_byname(); };}

View File

@@ -0,0 +1,126 @@
[locale.moneypunct.general]
# 28 Text processing library [[text]](./#text)
## 28.3 Localization library [[localization]](localization#locale.moneypunct.general)
### 28.3.4 Standard locale categories [[locale.categories]](locale.categories#locale.moneypunct.general)
#### 28.3.4.7 The monetary category [[category.monetary]](category.monetary#locale.moneypunct.general)
#### 28.3.4.7.4 Class template moneypunct [[locale.moneypunct]](locale.moneypunct#general)
#### 28.3.4.7.4.1 General [locale.moneypunct.general]
[🔗](#lib:moneypunct)
namespace std {class money_base {public:enum part { none, space, symbol, sign, value }; struct pattern { char field[4]; }; }; template<class charT, bool International = false>class moneypunct : public locale::facet, public money_base {public:using char_type = charT; using string_type = basic_string<charT>; explicit moneypunct(size_t refs = 0);
charT decimal_point() const;
charT thousands_sep() const;
string grouping() const;
string_type curr_symbol() const;
string_type positive_sign() const;
string_type negative_sign() const; int frac_digits() const;
pattern pos_format() const;
pattern neg_format() const; static locale::id id; static const bool intl = International; protected:~moneypunct(); virtual charT do_decimal_point() const; virtual charT do_thousands_sep() const; virtual string do_grouping() const; virtual string_type do_curr_symbol() const; virtual string_type do_positive_sign() const; virtual string_type do_negative_sign() const; virtual int do_frac_digits() const; virtual pattern do_pos_format() const; virtual pattern do_neg_format() const; };}
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L4465)
The moneypunct<> facet defines monetary formatting parameters
used by money_get<> and money_put<>[.](#1.sentence-1)
A monetary format is a sequence of four components,
specified by a pattern value p,
such that the part value static_cast<part>(p.field[i]) determines the ith component of the format[.](#1.sentence-2)[230](#footnote-230 "An array of char, rather than an array of part, is specified for pattern::field purely for efficiency.")
In the field member of a pattern object,
each value symbol, sign, value, and
either space or none appears exactly once[.](#1.sentence-3)
The value none, if present, is not first;
the value space, if present, is neither first nor last[.](#1.sentence-4)
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L4484)
Where none or space appears,
whitespace is permitted in the format,
except where none appears at the end,
in which case no whitespace is permitted[.](#2.sentence-1)
The value space indicates that
at least one space is required at that position[.](#2.sentence-2)
Where symbol appears,
the sequence of characters returned by curr_symbol() is permitted, and
can be required[.](#2.sentence-3)
Where sign appears,
the first (if any) of the sequence of characters returned bypositive_sign() or negative_sign() (respectively as the monetary value is non-negative or negative) is required[.](#2.sentence-4)
Any remaining characters of the sign sequence are required after
all other format components[.](#2.sentence-5)
Where value appears, the absolute numeric monetary value is required[.](#2.sentence-6)
[3](#3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L4502)
The format of the numeric monetary value is a decimal number:
value :
units fractionalopt
decimal-point digits
fractional :
decimal-point digitsopt
if frac_digits() returns a positive value, or
value :
units
otherwise[.](#3.sentence-1)
The symbol *decimal-point* indicates the character returned by decimal_point()[.](#3.sentence-2)
The other symbols are defined as follows:
units :
digits
digits thousands-sep units
digits :
adigit digitsopt
In the syntax specification,
the symbol *adigit* is any of the values ct.widen(c) for c in the range '0' through '9' (inclusive) andct is a reference of type const ctype<charT>& obtained as described in the definitions
of money_get<> and money_put<>[.](#3.sentence-4)
The symbol *thousands-sep* is the character returned by thousands_sep()[.](#3.sentence-5)
The space character used is the value ct.widen(' ')[.](#3.sentence-6)
Whitespace characters are those characters c for which ci.is(space, c) returns true[.](#3.sentence-7)
The number of digits required after the decimal point (if any)
is exactly the value returned by frac_digits()[.](#3.sentence-8)
[4](#4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L4548)
The placement of thousands-separator characters (if any)
is determined by the value returned by grouping(),
defined identically as the member numpunct<>::do_grouping()[.](#4.sentence-1)
[230)](#footnote-230)[230)](#footnoteref-230)
An array of char,
rather than an array of part,
is specified for pattern::field purely for efficiency[.](#footnote-230.sentence-1)

View File

@@ -0,0 +1,31 @@
[locale.moneypunct.members]
# 28 Text processing library [[text]](./#text)
## 28.3 Localization library [[localization]](localization#locale.moneypunct.members)
### 28.3.4 Standard locale categories [[locale.categories]](locale.categories#locale.moneypunct.members)
#### 28.3.4.7 The monetary category [[category.monetary]](category.monetary#locale.moneypunct.members)
#### 28.3.4.7.4 Class template moneypunct [[locale.moneypunct]](locale.moneypunct#members)
#### 28.3.4.7.4.2 Members [locale.moneypunct.members]
[🔗](#lib:moneypunct,decimal_point)
charT decimal_point() const;
charT thousands_sep() const;
string grouping() const;
string_type curr_symbol() const;
string_type positive_sign() const;
string_type negative_sign() const;int frac_digits() const;
pattern pos_format() const;
pattern neg_format() const;
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L4576)
Each of these functions *F* returns the result of calling the corresponding
virtual member functiondo_*F*()[.](#1.sentence-1)

View File

@@ -0,0 +1,147 @@
[locale.moneypunct.virtuals]
# 28 Text processing library [[text]](./#text)
## 28.3 Localization library [[localization]](localization#locale.moneypunct.virtuals)
### 28.3.4 Standard locale categories [[locale.categories]](locale.categories#locale.moneypunct.virtuals)
#### 28.3.4.7 The monetary category [[category.monetary]](category.monetary#locale.moneypunct.virtuals)
#### 28.3.4.7.4 Class template moneypunct [[locale.moneypunct]](locale.moneypunct#virtuals)
#### 28.3.4.7.4.3 Virtual functions [locale.moneypunct.virtuals]
[🔗](#lib:moneypunct,do_decimal_point)
`charT do_decimal_point() const;
`
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L4590)
*Returns*: The radix separator to use
in case do_frac_digits() is greater than zero[.](#1.sentence-1)[231](#footnote-231 "In common U.S. locales this is '.'.")
[🔗](#lib:moneypunct,do_thousands_sep)
`charT do_thousands_sep() const;
`
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L4605)
*Returns*: The digit group separator to use
in case do_grouping() specifies a digit grouping pattern[.](#2.sentence-1)[232](#footnote-232 "In common U.S. locales this is ','.")
[🔗](#lib:moneypunct,do_grouping)
`string do_grouping() const;
`
[3](#3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L4620)
*Returns*: A pattern defined identically as, but not necessarily equal to,
the result of numpunct<charT>::do_grouping()[.](#3.sentence-1)[233](#footnote-233 "To specify grouping by 3s, the value is &quot;\003&quot; not &quot;3&quot;.")
[🔗](#lib:moneypunct,do_curr_symbol)
`string_type do_curr_symbol() const;
`
[4](#4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L4636)
*Returns*: A string to use as the currency identifier symbol[.](#4.sentence-1)
[*Note [1](#note-1)*:
For specializations where the second template parameter is true,
this is typically four characters long:
a three-letter code as specified by ISO 4217[[bib]](bibliography#bib:iso4217 "Bibliography") followed by a space[.](#4.sentence-2)
— *end note*]
[🔗](#lib:moneypunct,do_positive_sign)
`string_type do_positive_sign() const;
string_type do_negative_sign() const;
`
[5](#5)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L4655)
*Returns*: do_positive_sign() returns the string to use to indicate a positive monetary value;[234](#footnote-234 "This is usually the empty string.")do_negative_sign() returns the string to use to indicate a negative value[.](#5.sentence-1)
[🔗](#lib:moneypunct,do_frac_digits)
`int do_frac_digits() const;
`
[6](#6)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L4672)
*Returns*: The number of digits after the decimal radix separator, if any[.](#6.sentence-1)[235](#footnote-235 "In common U.S.&nbsp;locales, this is 2.")
[🔗](#lib:moneypunct,do_pos_format)
`pattern do_pos_format() const;
pattern do_neg_format() const;
`
[7](#7)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L4688)
*Returns*: The specializations required in Table [92](locale.category#tab:locale.spec "Table 92: Required specializations") ([[locale.category]](locale.category "28.3.3.1.2.1Type locale::category")), namely
- [(7.1)](#7.1)
moneypunct<char>,
- [(7.2)](#7.2)
moneypunct<wchar_t>,
- [(7.3)](#7.3)
moneypunct<char, true>, and
- [(7.4)](#7.4)
moneypunct<wchar_t, true>,
return an object of type pattern initialized to { symbol, sign, none, value }[.](#7.sentence-1)[236](#footnote-236 "Note that the international symbol returned by do_­curr_­symbol() usually contains a space, itself; for example, &quot;USD &quot;.")
[231)](#footnote-231)[231)](#footnoteref-231)
In common U.S. locales this is '.'[.](#footnote-231.sentence-1)
[232)](#footnote-232)[232)](#footnoteref-232)
In common U.S. locales this is ','[.](#footnote-232.sentence-1)
[233)](#footnote-233)[233)](#footnoteref-233)
To specify grouping by 3s,
the value is "\003" *not* "3"[.](#footnote-233.sentence-1)
[234)](#footnote-234)[234)](#footnoteref-234)
This is usually the empty string[.](#footnote-234.sentence-1)
[235)](#footnote-235)[235)](#footnoteref-235)
In common U.S. locales, this is 2[.](#footnote-235.sentence-1)
[236)](#footnote-236)[236)](#footnoteref-236)
Note that the international symbol returned by do_curr_symbol() usually contains a space, itself;
for example, "USD "[.](#footnote-236.sentence-1)

245
cppdraft/locale/nm/put.md Normal file
View File

@@ -0,0 +1,245 @@
[locale.nm.put]
# 28 Text processing library [[text]](./#text)
## 28.3 Localization library [[localization]](localization#locale.nm.put)
### 28.3.4 Standard locale categories [[locale.categories]](locale.categories#locale.nm.put)
#### 28.3.4.3 The numeric category [[category.numeric]](category.numeric#locale.nm.put)
#### 28.3.4.3.3 Class template num_put [locale.nm.put]
#### [28.3.4.3.3.1](#general) General [[locale.nm.put.general]](locale.nm.put.general)
[🔗](#lib:num_put)
namespace std {template<class charT, class OutputIterator = ostreambuf_iterator<charT>>class num_put : public locale::facet {public:using char_type = charT; using iter_type = OutputIterator; explicit num_put(size_t refs = 0);
iter_type put(iter_type s, ios_base& f, char_type fill, bool v) const;
iter_type put(iter_type s, ios_base& f, char_type fill, long v) const;
iter_type put(iter_type s, ios_base& f, char_type fill, long long v) const;
iter_type put(iter_type s, ios_base& f, char_type fill, unsigned long v) const;
iter_type put(iter_type s, ios_base& f, char_type fill, unsigned long long v) const;
iter_type put(iter_type s, ios_base& f, char_type fill, double v) const;
iter_type put(iter_type s, ios_base& f, char_type fill, long double v) const;
iter_type put(iter_type s, ios_base& f, char_type fill, const void* v) const; static locale::id id; protected:~num_put(); virtual iter_type do_put(iter_type, ios_base&, char_type fill, bool v) const; virtual iter_type do_put(iter_type, ios_base&, char_type fill, long v) const; virtual iter_type do_put(iter_type, ios_base&, char_type fill, long long v) const; virtual iter_type do_put(iter_type, ios_base&, char_type fill, unsigned long) const; virtual iter_type do_put(iter_type, ios_base&, char_type fill, unsigned long long) const; virtual iter_type do_put(iter_type, ios_base&, char_type fill, double v) const; virtual iter_type do_put(iter_type, ios_base&, char_type fill, long double v) const; virtual iter_type do_put(iter_type, ios_base&, char_type fill, const void* v) const; };}
[1](#general-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L2841)
The facetnum_put is used to format numeric values to a character sequence such as an ostream[.](#general-1.sentence-1)
#### [28.3.4.3.3.2](#facet.num.put.members) Members [[facet.num.put.members]](facet.num.put.members)
[🔗](#lib:num_put,put)
`iter_type put(iter_type out, ios_base& str, char_type fill, bool val) const;
iter_type put(iter_type out, ios_base& str, char_type fill, long val) const;
iter_type put(iter_type out, ios_base& str, char_type fill, long long val) const;
iter_type put(iter_type out, ios_base& str, char_type fill, unsigned long val) const;
iter_type put(iter_type out, ios_base& str, char_type fill, unsigned long long val) const;
iter_type put(iter_type out, ios_base& str, char_type fill, double val) const;
iter_type put(iter_type out, ios_base& str, char_type fill, long double val) const;
iter_type put(iter_type out, ios_base& str, char_type fill, const void* val) const;
`
[1](#facet.num.put.members-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L2861)
*Returns*: do_put(out, str, fill, val)[.](#facet.num.put.members-1.sentence-1)
#### [28.3.4.3.3.3](#facet.num.put.virtuals) Virtual functions [[facet.num.put.virtuals]](facet.num.put.virtuals)
[🔗](#lib:num_put,do_put)
`iter_type do_put(iter_type out, ios_base& str, char_type fill, long val) const;
iter_type do_put(iter_type out, ios_base& str, char_type fill, long long val) const;
iter_type do_put(iter_type out, ios_base& str, char_type fill, unsigned long val) const;
iter_type do_put(iter_type out, ios_base& str, char_type fill, unsigned long long val) const;
iter_type do_put(iter_type out, ios_base& str, char_type fill, double val) const;
iter_type do_put(iter_type out, ios_base& str, char_type fill, long double val) const;
iter_type do_put(iter_type out, ios_base& str, char_type fill, const void* val) const;
`
[1](#facet.num.put.virtuals-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L2880)
*Effects*: Writes characters to the sequence out,
formatting val as desired[.](#facet.num.put.virtuals-1.sentence-1)
In the following description, loc names a local variable initialized aslocale loc = str.getloc();
[2](#facet.num.put.virtuals-2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L2889)
The details of this operation occur in several stages:
- [(2.1)](#facet.num.put.virtuals-2.1)
Stage 1:
Determine a printf conversion specifier spec and
determine the characters
that would be printed by printf ([[c.files]](c.files "31.13C library files"))
given this conversion specifier forprintf(spec, val) assuming that the current locale is the "C" locale[.](#facet.num.put.virtuals-2.1.sentence-1)
- [(2.2)](#facet.num.put.virtuals-2.2)
Stage 2:
Adjust the representation by converting
each char determined by stage 1 to a charT using a conversion and
values returned by members of use_facet<numpunct<charT>>(loc)[.](#facet.num.put.virtuals-2.2.sentence-1)
- [(2.3)](#facet.num.put.virtuals-2.3)
Stage 3:
Determine where padding is required[.](#facet.num.put.virtuals-2.3.sentence-1)
- [(2.4)](#facet.num.put.virtuals-2.4)
Stage 4:
Insert the sequence into the out[.](#facet.num.put.virtuals-2.4.sentence-1)
[3](#facet.num.put.virtuals-3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L2917)
Detailed descriptions of each stage follow[.](#facet.num.put.virtuals-3.sentence-1)
[4](#facet.num.put.virtuals-4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L2920)
*Returns*: out[.](#facet.num.put.virtuals-4.sentence-1)
[5](#facet.num.put.virtuals-5)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L2924)
- [Stage 1:](#facet.num.put.virtuals-5.1)
The first action of stage 1 is to determine a conversion specifier[.](#facet.num.put.virtuals-5.1.sentence-1)
The tables that describe this determination use the following local variables
fmtflags flags = str.flags();
fmtflags basefield = (flags & (ios_base::basefield));
fmtflags uppercase = (flags & (ios_base::uppercase));
fmtflags floatfield = (flags & (ios_base::floatfield));
fmtflags showpos = (flags & (ios_base::showpos));
fmtflags showbase = (flags & (ios_base::showbase));
fmtflags showpoint = (flags & (ios_base::showpoint));
All tables used in describing stage 1 are ordered[.](#facet.num.put.virtuals-5.1.sentence-3)
That is, the first line whose condition is true applies[.](#facet.num.put.virtuals-5.1.sentence-4)
A line without a condition is the default behavior
when none of the earlier lines apply[.](#facet.num.put.virtuals-5.1.sentence-5)
For conversion from an integral type other than a character type,
the function determines the integral conversion specifier
as indicated in Table [97](#tab:facet.num.put.int "Table 97: Integer conversions")[.](#facet.num.put.virtuals-5.1.sentence-6)
Table [97](#tab:facet.num.put.int) — Integer conversions [[tab:facet.num.put.int]](./tab:facet.num.put.int)
| [🔗](#tab:facet.num.put.int-row-1)<br> **State** | **stdio equivalent** |
| --- | --- |
| [🔗](#tab:facet.num.put.int-row-2)<br> basefield == ios_base::oct | %o |
| [🔗](#tab:facet.num.put.int-row-3)<br> (basefield == ios_base::hex) && !uppercase | %x |
| [🔗](#tab:facet.num.put.int-row-4)<br> (basefield == ios_base::hex) | %X |
| [🔗](#tab:facet.num.put.int-row-5)<br> for a signed integral type | %d |
| [🔗](#tab:facet.num.put.int-row-6)<br> for an unsigned integral type | %u |
For conversion from a floating-point type,
the function determines the floating-point conversion specifier
as indicated in Table [98](#tab:facet.num.put.fp "Table 98: Floating-point conversions")[.](#facet.num.put.virtuals-5.1.sentence-7)
Table [98](#tab:facet.num.put.fp) — Floating-point conversions [[tab:facet.num.put.fp]](./tab:facet.num.put.fp)
| [🔗](#tab:facet.num.put.fp-row-1)<br> **State** | **stdio equivalent** |
| --- | --- |
| [🔗](#tab:facet.num.put.fp-row-2)<br> floatfield == ios_base::fixed && !uppercase | %f |
| [🔗](#tab:facet.num.put.fp-row-3)<br> floatfield == ios_base::fixed | %F |
| [🔗](#tab:facet.num.put.fp-row-4)<br> floatfield == ios_base::scientific && !uppercase | %e |
| [🔗](#tab:facet.num.put.fp-row-5)<br> floatfield == ios_base::scientific | %E |
| [🔗](#tab:facet.num.put.fp-row-6)<br> floatfield == (ios_base::fixed | ios_base::scientific) && !uppercase | %a |
| [🔗](#tab:facet.num.put.fp-row-7)<br> floatfield == (ios_base::fixed | ios_base::scientific) | %A |
| [🔗](#tab:facet.num.put.fp-row-8)<br> !uppercase | %g |
| [🔗](#tab:facet.num.put.fp-row-9)<br> *otherwise* | %G |
For conversions from an integral or floating-point type
a length modifier is added to the conversion specifier
as indicated in Table [99](#tab:facet.num.put.length "Table 99: Length modifier")[.](#facet.num.put.virtuals-5.1.sentence-8)
Table [99](#tab:facet.num.put.length) — Length modifier [[tab:facet.num.put.length]](./tab:facet.num.put.length)
| [🔗](#tab:facet.num.put.length-row-1)<br> **Type** | **Length modifier** |
| --- | --- |
| [🔗](#tab:facet.num.put.length-row-2)<br> long | l |
| [🔗](#tab:facet.num.put.length-row-3)<br> long long | ll |
| [🔗](#tab:facet.num.put.length-row-4)<br> unsigned long | l |
| [🔗](#tab:facet.num.put.length-row-5)<br> unsigned long long | ll |
| [🔗](#tab:facet.num.put.length-row-6)<br> long double | L |
| [🔗](#tab:facet.num.put.length-row-7)<br> *otherwise* | *none* |
The conversion specifier has the following optional additional qualifiers
prepended as indicated in Table [100](#tab:facet.num.put.conv "Table 100: Numeric conversions")[.](#facet.num.put.virtuals-5.1.sentence-9)
Table [100](#tab:facet.num.put.conv) — Numeric conversions [[tab:facet.num.put.conv]](./tab:facet.num.put.conv)
| [🔗](#tab:facet.num.put.conv-row-1)<br> **Type(s)** | **State** | **stdio equivalent** |
| --- | --- | --- |
| [🔗](#tab:facet.num.put.conv-row-2)<br> an integral type | showpos | + |
| [🔗](#tab:facet.num.put.conv-row-3) | showbase | # |
| [🔗](#tab:facet.num.put.conv-row-4)<br> a floating-point type | showpos | + |
| [🔗](#tab:facet.num.put.conv-row-5) | showpoint | # |
For conversion from a floating-point type,
if floatfield != (ios_base::fixed | ios_base::scientific),str.precision() is specified as precision
in the conversion specification[.](#facet.num.put.virtuals-5.1.sentence-10)
Otherwise, no precision is specified[.](#facet.num.put.virtuals-5.1.sentence-11)
For conversion from void* the specifier is %p[.](#facet.num.put.virtuals-5.1.sentence-12)
The representations at the end of stage 1 consists of the char's
that would be printed by a call of printf(s, val) where s is the conversion specifier determined above[.](#facet.num.put.virtuals-5.1.sentence-13)
- [Stage 2:](#facet.num.put.virtuals-5.2)
Any character c other than a decimal point(.) is converted to
a charT viause_facet<ctype<charT>>(loc).widen(c)
A local variable punct is initialized viaconst numpunct<charT>& punct = use_facet<numpunct<charT>>(loc);
For arithmetic types,punct.thousands_sep() characters are inserted into
the sequence as determined by the value returned by punct.do_grouping() using the method described in [[facet.numpunct.virtuals]](facet.numpunct.virtuals "28.3.4.4.1.3Virtual functions")[.](#facet.num.put.virtuals-5.2.sentence-3)
Decimal point characters(.) are replaced by punct.decimal_point()[.](#facet.num.put.virtuals-5.2.sentence-4)
- [Stage 3:](#facet.num.put.virtuals-5.3)
A local variable is initialized asfmtflags adjustfield = (flags & (ios_base::adjustfield));
The location of any padding[224](#footnote-224 "The conversion specification #o generates a leading 0 which is not a padding character.") is determined according to Table [101](#tab:facet.num.put.fill "Table 101: Fill padding")[.](#facet.num.put.virtuals-5.3.sentence-2)
Table [101](#tab:facet.num.put.fill) — Fill padding [[tab:facet.num.put.fill]](./tab:facet.num.put.fill)
| [🔗](#tab:facet.num.put.fill-row-1)<br> **State** | **Location** |
| --- | --- |
| [🔗](#tab:facet.num.put.fill-row-2)<br> adjustfield == ios_base::left | pad after |
| [🔗](#tab:facet.num.put.fill-row-3)<br> adjustfield == ios_base::right | pad before |
| [🔗](#tab:facet.num.put.fill-row-4)<br> adjustfield == internal and a sign occurs in the representation | pad after the sign |
| [🔗](#tab:facet.num.put.fill-row-5)<br> adjustfield == internal and representation after stage 1 began with 0x or 0X | pad after x or X |
| [🔗](#tab:facet.num.put.fill-row-6)<br> *otherwise* | pad before |
If str.width() is nonzero and the number of charT's
in the sequence after stage 2 is less than str.width(),
then enough fill characters are added to the sequence
at the position indicated for padding
to bring the length of the sequence to str.width()[.](#facet.num.put.virtuals-5.3.sentence-3)
str.width(0) is called[.](#facet.num.put.virtuals-5.3.sentence-4)
- [Stage 4:](#facet.num.put.virtuals-5.4)
The sequence of charT's at the end of stage 3 are output via*out++ = c
[🔗](#lib:do_put,num_put_)
`iter_type do_put(iter_type out, ios_base& str, char_type fill, bool val) const;
`
[6](#facet.num.put.virtuals-6)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L3086)
*Returns*: If (str.flags() & ios_base::boolalpha) == 0 returns do_put(out, str, fill,
(int)val),
otherwise obtains a string s as if bystring_type s = val ? use_facet<numpunct<charT>>(loc).truename(): use_facet<numpunct<charT>>(loc).falsename(); and then inserts each character c of s into out via *out++ = c and returns out[.](#facet.num.put.virtuals-6.sentence-1)
[224)](#footnote-224)[224)](#footnoteref-224)
The conversion specification #o generates a leading 0 which is *not* a padding character[.](#footnote-224.sentence-1)

View File

@@ -0,0 +1,32 @@
[locale.nm.put.general]
# 28 Text processing library [[text]](./#text)
## 28.3 Localization library [[localization]](localization#locale.nm.put.general)
### 28.3.4 Standard locale categories [[locale.categories]](locale.categories#locale.nm.put.general)
#### 28.3.4.3 The numeric category [[category.numeric]](category.numeric#locale.nm.put.general)
#### 28.3.4.3.3 Class template num_put [[locale.nm.put]](locale.nm.put#general)
#### 28.3.4.3.3.1 General [locale.nm.put.general]
[🔗](#lib:num_put)
namespace std {template<class charT, class OutputIterator = ostreambuf_iterator<charT>>class num_put : public locale::facet {public:using char_type = charT; using iter_type = OutputIterator; explicit num_put(size_t refs = 0);
iter_type put(iter_type s, ios_base& f, char_type fill, bool v) const;
iter_type put(iter_type s, ios_base& f, char_type fill, long v) const;
iter_type put(iter_type s, ios_base& f, char_type fill, long long v) const;
iter_type put(iter_type s, ios_base& f, char_type fill, unsigned long v) const;
iter_type put(iter_type s, ios_base& f, char_type fill, unsigned long long v) const;
iter_type put(iter_type s, ios_base& f, char_type fill, double v) const;
iter_type put(iter_type s, ios_base& f, char_type fill, long double v) const;
iter_type put(iter_type s, ios_base& f, char_type fill, const void* v) const; static locale::id id; protected:~num_put(); virtual iter_type do_put(iter_type, ios_base&, char_type fill, bool v) const; virtual iter_type do_put(iter_type, ios_base&, char_type fill, long v) const; virtual iter_type do_put(iter_type, ios_base&, char_type fill, long long v) const; virtual iter_type do_put(iter_type, ios_base&, char_type fill, unsigned long) const; virtual iter_type do_put(iter_type, ios_base&, char_type fill, unsigned long long) const; virtual iter_type do_put(iter_type, ios_base&, char_type fill, double v) const; virtual iter_type do_put(iter_type, ios_base&, char_type fill, long double v) const; virtual iter_type do_put(iter_type, ios_base&, char_type fill, const void* v) const; };}
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L2841)
The facetnum_put is used to format numeric values to a character sequence such as an ostream[.](#1.sentence-1)

369
cppdraft/locale/num/get.md Normal file
View File

@@ -0,0 +1,369 @@
[locale.num.get]
# 28 Text processing library [[text]](./#text)
## 28.3 Localization library [[localization]](localization#locale.num.get)
### 28.3.4 Standard locale categories [[locale.categories]](locale.categories#locale.num.get)
#### 28.3.4.3 The numeric category [[category.numeric]](category.numeric#locale.num.get)
#### 28.3.4.3.2 Class template num_get [locale.num.get]
#### [28.3.4.3.2.1](#general) General [[locale.num.get.general]](locale.num.get.general)
[🔗](#lib:num_get)
namespace std {template<class charT, class InputIterator = istreambuf_iterator<charT>>class num_get : public locale::facet {public:using char_type = charT; using iter_type = InputIterator; explicit num_get(size_t refs = 0);
iter_type get(iter_type in, iter_type end, ios_base&,
ios_base::iostate& err, bool& v) const;
iter_type get(iter_type in, iter_type end, ios_base&,
ios_base::iostate& err, long& v) const;
iter_type get(iter_type in, iter_type end, ios_base&,
ios_base::iostate& err, long long& v) const;
iter_type get(iter_type in, iter_type end, ios_base&,
ios_base::iostate& err, unsigned short& v) const;
iter_type get(iter_type in, iter_type end, ios_base&,
ios_base::iostate& err, unsigned int& v) const;
iter_type get(iter_type in, iter_type end, ios_base&,
ios_base::iostate& err, unsigned long& v) const;
iter_type get(iter_type in, iter_type end, ios_base&,
ios_base::iostate& err, unsigned long long& v) const;
iter_type get(iter_type in, iter_type end, ios_base&,
ios_base::iostate& err, float& v) const;
iter_type get(iter_type in, iter_type end, ios_base&,
ios_base::iostate& err, double& v) const;
iter_type get(iter_type in, iter_type end, ios_base&,
ios_base::iostate& err, long double& v) const;
iter_type get(iter_type in, iter_type end, ios_base&,
ios_base::iostate& err, void*& v) const; static locale::id id; protected:~num_get(); virtual iter_type do_get(iter_type, iter_type, ios_base&,
ios_base::iostate& err, bool& v) const; virtual iter_type do_get(iter_type, iter_type, ios_base&,
ios_base::iostate& err, long& v) const; virtual iter_type do_get(iter_type, iter_type, ios_base&,
ios_base::iostate& err, long long& v) const; virtual iter_type do_get(iter_type, iter_type, ios_base&,
ios_base::iostate& err, unsigned short& v) const; virtual iter_type do_get(iter_type, iter_type, ios_base&,
ios_base::iostate& err, unsigned int& v) const; virtual iter_type do_get(iter_type, iter_type, ios_base&,
ios_base::iostate& err, unsigned long& v) const; virtual iter_type do_get(iter_type, iter_type, ios_base&,
ios_base::iostate& err, unsigned long long& v) const; virtual iter_type do_get(iter_type, iter_type, ios_base&,
ios_base::iostate& err, float& v) const; virtual iter_type do_get(iter_type, iter_type, ios_base&,
ios_base::iostate& err, double& v) const; virtual iter_type do_get(iter_type, iter_type, ios_base&,
ios_base::iostate& err, long double& v) const; virtual iter_type do_get(iter_type, iter_type, ios_base&,
ios_base::iostate& err, void*& v) const; };}
[1](#general-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L2490)
The facet num_get is used to parse numeric values
from an input sequence such as an istream[.](#general-1.sentence-1)
#### [28.3.4.3.2.2](#facet.num.get.members) Members [[facet.num.get.members]](facet.num.get.members)
[🔗](#lib:num_get,get)
`iter_type get(iter_type in, iter_type end, ios_base& str,
ios_base::iostate& err, bool& val) const;
iter_type get(iter_type in, iter_type end, ios_base& str,
ios_base::iostate& err, long& val) const;
iter_type get(iter_type in, iter_type end, ios_base& str,
ios_base::iostate& err, long long& val) const;
iter_type get(iter_type in, iter_type end, ios_base& str,
ios_base::iostate& err, unsigned short& val) const;
iter_type get(iter_type in, iter_type end, ios_base& str,
ios_base::iostate& err, unsigned int& val) const;
iter_type get(iter_type in, iter_type end, ios_base& str,
ios_base::iostate& err, unsigned long& val) const;
iter_type get(iter_type in, iter_type end, ios_base& str,
ios_base::iostate& err, unsigned long long& val) const;
iter_type get(iter_type in, iter_type end, ios_base& str,
ios_base::iostate& err, float& val) const;
iter_type get(iter_type in, iter_type end, ios_base& str,
ios_base::iostate& err, double& val) const;
iter_type get(iter_type in, iter_type end, ios_base& str,
ios_base::iostate& err, long double& val) const;
iter_type get(iter_type in, iter_type end, ios_base& str,
ios_base::iostate& err, void*& val) const;
`
[1](#facet.num.get.members-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L2523)
*Returns*: do_get(in, end, str, err, val)[.](#facet.num.get.members-1.sentence-1)
#### [28.3.4.3.2.3](#facet.num.get.virtuals) Virtual functions [[facet.num.get.virtuals]](facet.num.get.virtuals)
[🔗](#lib:num_get,do_get)
`iter_type do_get(iter_type in, iter_type end, ios_base& str,
ios_base::iostate& err, long& val) const;
iter_type do_get(iter_type in, iter_type end, ios_base& str,
ios_base::iostate& err, long long& val) const;
iter_type do_get(iter_type in, iter_type end, ios_base& str,
ios_base::iostate& err, unsigned short& val) const;
iter_type do_get(iter_type in, iter_type end, ios_base& str,
ios_base::iostate& err, unsigned int& val) const;
iter_type do_get(iter_type in, iter_type end, ios_base& str,
ios_base::iostate& err, unsigned long& val) const;
iter_type do_get(iter_type in, iter_type end, ios_base& str,
ios_base::iostate& err, unsigned long long& val) const;
iter_type do_get(iter_type in, iter_type end, ios_base& str,
ios_base::iostate& err, float& val) const;
iter_type do_get(iter_type in, iter_type end, ios_base& str,
ios_base::iostate& err, double& val) const;
iter_type do_get(iter_type in, iter_type end, ios_base& str,
ios_base::iostate& err, long double& val) const;
iter_type do_get(iter_type in, iter_type end, ios_base& str,
ios_base::iostate& err, void*& val) const;
`
[1](#facet.num.get.virtuals-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L2555)
*Effects*: Reads characters from in,
interpreting them according tostr.flags(),use_facet<ctype<charT>>(loc), anduse_facet<numpunct<charT>>(loc),
where loc is str.getloc()[.](#facet.num.get.virtuals-1.sentence-1)
[2](#facet.num.get.virtuals-2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L2564)
The details of this operation occur in three stages:
- [(2.1)](#facet.num.get.virtuals-2.1)
Stage 1:
Determine a conversion specifier[.](#facet.num.get.virtuals-2.1.sentence-1)
- [(2.2)](#facet.num.get.virtuals-2.2)
Stage 2:
Extract characters from in and
determine a corresponding char value for
the format expected by the conversion specification determined in stage 1[.](#facet.num.get.virtuals-2.2.sentence-1)
- [(2.3)](#facet.num.get.virtuals-2.3)
Stage 3:
Store results[.](#facet.num.get.virtuals-2.3.sentence-1)
[3](#facet.num.get.virtuals-3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L2581)
The details of the stages are presented below[.](#facet.num.get.virtuals-3.sentence-1)
- [Stage 1:](#facet.num.get.virtuals-3.1)
The function initializes local variables viafmtflags flags = str.flags();
fmtflags basefield = (flags & ios_base::basefield);
fmtflags uppercase = (flags & ios_base::uppercase);
fmtflags boolalpha = (flags & ios_base::boolalpha);
For conversion to an integral type,
the function determines the integral conversion specifier
as indicated in Table [95](#tab:facet.num.get.int "Table 95: Integer conversions")[.](#facet.num.get.virtuals-3.1.sentence-2)
The table is ordered[.](#facet.num.get.virtuals-3.1.sentence-3)
That is, the first line whose condition is true applies[.](#facet.num.get.virtuals-3.1.sentence-4)
Table [95](#tab:facet.num.get.int) — Integer conversions [[tab:facet.num.get.int]](./tab:facet.num.get.int)
| [🔗](#tab:facet.num.get.int-row-1)<br> **State** | **stdio equivalent** |
| --- | --- |
| [🔗](#tab:facet.num.get.int-row-2)<br> basefield == oct | %o |
| [🔗](#tab:facet.num.get.int-row-3)<br> basefield == hex | %X |
| [🔗](#tab:facet.num.get.int-row-4)<br> basefield == 0 | %i |
| [🔗](#tab:facet.num.get.int-row-5)<br> signed integral type | %d |
| [🔗](#tab:facet.num.get.int-row-6)<br> unsigned integral type | %u |
For conversions to a floating-point type the specifier is %g[.](#facet.num.get.virtuals-3.1.sentence-5)
For conversions to void* the specifier is %p[.](#facet.num.get.virtuals-3.1.sentence-6)
A length modifier is added to the conversion specification, if needed,
as indicated in Table [96](#tab:facet.num.get.length "Table 96: Length modifier")[.](#facet.num.get.virtuals-3.1.sentence-7)
Table [96](#tab:facet.num.get.length) — Length modifier [[tab:facet.num.get.length]](./tab:facet.num.get.length)
| [🔗](#tab:facet.num.get.length-row-1)<br> **Type** | **Length modifier** |
| --- | --- |
| [🔗](#tab:facet.num.get.length-row-2)<br> short | h |
| [🔗](#tab:facet.num.get.length-row-3)<br> unsigned short | h |
| [🔗](#tab:facet.num.get.length-row-4)<br> long | l |
| [🔗](#tab:facet.num.get.length-row-5)<br> unsigned long | l |
| [🔗](#tab:facet.num.get.length-row-6)<br> long long | ll |
| [🔗](#tab:facet.num.get.length-row-7)<br> unsigned long long | ll |
| [🔗](#tab:facet.num.get.length-row-8)<br> double | l |
| [🔗](#tab:facet.num.get.length-row-9)<br> long double | L |
- [Stage 2:](#facet.num.get.virtuals-3.2)
If in == end then stage 2 terminates[.](#facet.num.get.virtuals-3.2.sentence-1)
Otherwise a charT is taken from in and
local variables are initialized as if bychar_type ct = *in;char c = src[find(atoms, atoms + sizeof(src) - 1, ct) - atoms];if (ct == use_facet<numpunct<charT>>(loc).decimal_point()) c = '.';bool discard = ct == use_facet<numpunct<charT>>(loc).thousands_sep()&& use_facet<numpunct<charT>>(loc).grouping().length() != 0; where the values src and atoms are defined as if by:static const char src[] = "0123456789abcdefpxABCDEFPX+-";
char_type atoms[sizeof(src)];
use_facet<ctype<charT>>(loc).widen(src, src + sizeof(src), atoms); for this value of loc[.](#facet.num.get.virtuals-3.2.sentence-2)
If discard is true,
then if '.' has not yet been accumulated,
then the position of the character is remembered,
but the character is otherwise ignored[.](#facet.num.get.virtuals-3.2.sentence-3)
Otherwise, if '.' has already been accumulated,
the character is discarded and Stage 2 terminates[.](#facet.num.get.virtuals-3.2.sentence-4)
If it is not discarded,
then a check is made to determine
if c is allowed as the next character of
an input field of the conversion specifier returned by Stage 1[.](#facet.num.get.virtuals-3.2.sentence-5)
If so, it is accumulated[.](#facet.num.get.virtuals-3.2.sentence-6)
If the character is either discarded or accumulated
then in is advanced by ++in and processing returns to the beginning of stage 2[.](#facet.num.get.virtuals-3.2.sentence-7)
[*Example [1](#facet.num.get.virtuals-example-1)*:
Given an input sequence of "0x1a.bp+07p",
* [(3.2.1)](#facet.num.get.virtuals-3.2.1)
if the conversion specifier returned by Stage 1 is %d,"0" is accumulated;
* [(3.2.2)](#facet.num.get.virtuals-3.2.2)
if the conversion specifier returned by Stage 1 is %i,"0x1a" are accumulated;
* [(3.2.3)](#facet.num.get.virtuals-3.2.3)
if the conversion specifier returned by Stage 1 is %g,"0x1a.bp+07" are accumulated[.](#facet.num.get.virtuals-3.2.sentence-8)
In all cases, the remainder is left in the input[.](#facet.num.get.virtuals-3.2.sentence-9)
— *end example*]
- [Stage 3:](#facet.num.get.virtuals-3.3)
The sequence of chars accumulated in stage 2 (the field)
is converted to a numeric value by the rules of one of the functions
declared in the header [<cstdlib>](cstdlib.syn#header:%3ccstdlib%3e "17.2.2Header <cstdlib> synopsis[cstdlib.syn]"):
* [(3.3.1)](#facet.num.get.virtuals-3.3.1)
For a signed integer value, the function strtoll[.](#facet.num.get.virtuals-3.3.1.sentence-1)
* [(3.3.2)](#facet.num.get.virtuals-3.3.2)
For an unsigned integer value, the function strtoull[.](#facet.num.get.virtuals-3.3.2.sentence-1)
* [(3.3.3)](#facet.num.get.virtuals-3.3.3)
For a float value, the function strtof[.](#facet.num.get.virtuals-3.3.3.sentence-1)
* [(3.3.4)](#facet.num.get.virtuals-3.3.4)
For a double value, the function strtod[.](#facet.num.get.virtuals-3.3.4.sentence-1)
* [(3.3.5)](#facet.num.get.virtuals-3.3.5)
For a long double value, the function strtold[.](#facet.num.get.virtuals-3.3.5.sentence-1)
The numeric value to be stored can be one of:
* [(3.3.6)](#facet.num.get.virtuals-3.3.6)
zero, if the conversion function does not convert the entire field[.](#facet.num.get.virtuals-3.3.6.sentence-1)
* [(3.3.7)](#facet.num.get.virtuals-3.3.7)
the most positive (or negative) representable value,
if the field to be converted to a signed integer type represents a value
too large positive (or negative) to be represented in val[.](#facet.num.get.virtuals-3.3.7.sentence-1)
* [(3.3.8)](#facet.num.get.virtuals-3.3.8)
the most positive representable value,
if the field to be converted to an unsigned integer type represents a value
that cannot be represented in val[.](#facet.num.get.virtuals-3.3.8.sentence-1)
* [(3.3.9)](#facet.num.get.virtuals-3.3.9)
the converted value, otherwise[.](#facet.num.get.virtuals-3.3.9.sentence-1)
The resultant numeric value is stored in val[.](#facet.num.get.virtuals-3.3.sentence-3)
If the conversion function does not convert the entire field, or
if the field represents a value outside the range of representable values,ios_base::failbit is assigned to err[.](#facet.num.get.virtuals-3.3.sentence-4)
[4](#facet.num.get.virtuals-4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L2726)
Digit grouping is checked[.](#facet.num.get.virtuals-4.sentence-1)
That is, the positions of discarded
separators are examined for consistency withuse_facet<numpunct<charT>>(loc).grouping()[.](#facet.num.get.virtuals-4.sentence-2)
If they are not consistent
then ios_base::failbit is assigned to err[.](#facet.num.get.virtuals-4.sentence-3)
[5](#facet.num.get.virtuals-5)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L2734)
In any case,
if stage 2 processing was terminated by the test for in == end then err |= ios_base::eofbit is performed[.](#facet.num.get.virtuals-5.sentence-1)
[🔗](#lib:do_get,num_get_)
`iter_type do_get(iter_type in, iter_type end, ios_base& str,
ios_base::iostate& err, bool& val) const;
`
[6](#facet.num.get.virtuals-6)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L2747)
*Effects*: If (str.flags() & ios_base::boolalpha) == 0 then input proceeds as it would for a long except that if a value is being stored into val,
the value is determined according to the following:
If the value to be stored is 0 then false is stored[.](#facet.num.get.virtuals-6.sentence-1)
If the value is 1 then true is stored[.](#facet.num.get.virtuals-6.sentence-2)
Otherwise true is stored andios_base::failbit is assigned to err[.](#facet.num.get.virtuals-6.sentence-3)
[7](#facet.num.get.virtuals-7)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L2758)
Otherwise target sequences are determined “as if” by
calling the members falsename() and truename() of
the facet obtained by use_facet<numpunct<charT>>(str.getloc())[.](#facet.num.get.virtuals-7.sentence-1)
Successive characters in the range [in, end) (see [[sequence.reqmts]](sequence.reqmts "23.2.4Sequence containers"))
are obtained and matched against
corresponding positions in the target sequences
only as necessary to identify a unique match[.](#facet.num.get.virtuals-7.sentence-2)
The input iterator in is compared to end only when necessary to obtain a character[.](#facet.num.get.virtuals-7.sentence-3)
If a target sequence is uniquely matched,val is set to the corresponding value[.](#facet.num.get.virtuals-7.sentence-4)
Otherwise false is stored andios_base::failbit is assigned to err[.](#facet.num.get.virtuals-7.sentence-5)
[8](#facet.num.get.virtuals-8)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L2773)
The in iterator is always left pointing one position beyond
the last character successfully matched[.](#facet.num.get.virtuals-8.sentence-1)
If val is set, then err is set to str.goodbit;
or to str.eofbit if,
when seeking another character to match,
it is found that (in == end)[.](#facet.num.get.virtuals-8.sentence-2)
If val is not set, then err is set to str.failbit;
or to (str.failbit | str.eofbit) if the reason for the failure was that (in == end)[.](#facet.num.get.virtuals-8.sentence-3)
[*Example [2](#facet.num.get.virtuals-example-2)*:
For targets true: "a" and false: "abb",
the input sequence "a" yieldsval == true and err == str.eofbit;
the input sequence "abc" yieldserr = str.failbit, with in ending at the 'c' element[.](#facet.num.get.virtuals-8.sentence-4)
For targets true: "1" and false: "0",
the input sequence "1" yieldsval == true and err == str.goodbit[.](#facet.num.get.virtuals-8.sentence-5)
For empty targets (""),
any input sequence yields err == str.failbit[.](#facet.num.get.virtuals-8.sentence-6)
— *end example*]
[9](#facet.num.get.virtuals-9)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L2796)
*Returns*: in[.](#facet.num.get.virtuals-9.sentence-1)

View File

@@ -0,0 +1,58 @@
[locale.num.get.general]
# 28 Text processing library [[text]](./#text)
## 28.3 Localization library [[localization]](localization#locale.num.get.general)
### 28.3.4 Standard locale categories [[locale.categories]](locale.categories#locale.num.get.general)
#### 28.3.4.3 The numeric category [[category.numeric]](category.numeric#locale.num.get.general)
#### 28.3.4.3.2 Class template num_get [[locale.num.get]](locale.num.get#general)
#### 28.3.4.3.2.1 General [locale.num.get.general]
[🔗](#lib:num_get)
namespace std {template<class charT, class InputIterator = istreambuf_iterator<charT>>class num_get : public locale::facet {public:using char_type = charT; using iter_type = InputIterator; explicit num_get(size_t refs = 0);
iter_type get(iter_type in, iter_type end, ios_base&,
ios_base::iostate& err, bool& v) const;
iter_type get(iter_type in, iter_type end, ios_base&,
ios_base::iostate& err, long& v) const;
iter_type get(iter_type in, iter_type end, ios_base&,
ios_base::iostate& err, long long& v) const;
iter_type get(iter_type in, iter_type end, ios_base&,
ios_base::iostate& err, unsigned short& v) const;
iter_type get(iter_type in, iter_type end, ios_base&,
ios_base::iostate& err, unsigned int& v) const;
iter_type get(iter_type in, iter_type end, ios_base&,
ios_base::iostate& err, unsigned long& v) const;
iter_type get(iter_type in, iter_type end, ios_base&,
ios_base::iostate& err, unsigned long long& v) const;
iter_type get(iter_type in, iter_type end, ios_base&,
ios_base::iostate& err, float& v) const;
iter_type get(iter_type in, iter_type end, ios_base&,
ios_base::iostate& err, double& v) const;
iter_type get(iter_type in, iter_type end, ios_base&,
ios_base::iostate& err, long double& v) const;
iter_type get(iter_type in, iter_type end, ios_base&,
ios_base::iostate& err, void*& v) const; static locale::id id; protected:~num_get(); virtual iter_type do_get(iter_type, iter_type, ios_base&,
ios_base::iostate& err, bool& v) const; virtual iter_type do_get(iter_type, iter_type, ios_base&,
ios_base::iostate& err, long& v) const; virtual iter_type do_get(iter_type, iter_type, ios_base&,
ios_base::iostate& err, long long& v) const; virtual iter_type do_get(iter_type, iter_type, ios_base&,
ios_base::iostate& err, unsigned short& v) const; virtual iter_type do_get(iter_type, iter_type, ios_base&,
ios_base::iostate& err, unsigned int& v) const; virtual iter_type do_get(iter_type, iter_type, ios_base&,
ios_base::iostate& err, unsigned long& v) const; virtual iter_type do_get(iter_type, iter_type, ios_base&,
ios_base::iostate& err, unsigned long long& v) const; virtual iter_type do_get(iter_type, iter_type, ios_base&,
ios_base::iostate& err, float& v) const; virtual iter_type do_get(iter_type, iter_type, ios_base&,
ios_base::iostate& err, double& v) const; virtual iter_type do_get(iter_type, iter_type, ios_base&,
ios_base::iostate& err, long double& v) const; virtual iter_type do_get(iter_type, iter_type, ios_base&,
ios_base::iostate& err, void*& v) const; };}
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L2490)
The facet num_get is used to parse numeric values
from an input sequence such as an istream[.](#1.sentence-1)

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)

View File

@@ -0,0 +1,15 @@
[locale.numpunct.byname]
# 28 Text processing library [[text]](./#text)
## 28.3 Localization library [[localization]](localization#locale.numpunct.byname)
### 28.3.4 Standard locale categories [[locale.categories]](locale.categories#locale.numpunct.byname)
#### 28.3.4.4 The numeric punctuation facet [[facet.numpunct]](facet.numpunct#locale.numpunct.byname)
#### 28.3.4.4.2 Class template numpunct_byname [locale.numpunct.byname]
[🔗](#lib:numpunct_byname)
namespace std {template<class charT>class numpunct_byname : public numpunct<charT> {// this class is specialized for char and wchar_t.public:using char_type = charT; using string_type = basic_string<charT>; explicit numpunct_byname(const char*, size_t refs = 0); explicit numpunct_byname(const string&, size_t refs = 0); protected:~numpunct_byname(); };}

View File

@@ -0,0 +1,83 @@
[locale.numpunct.general]
# 28 Text processing library [[text]](./#text)
## 28.3 Localization library [[localization]](localization#locale.numpunct.general)
### 28.3.4 Standard locale categories [[locale.categories]](locale.categories#locale.numpunct.general)
#### 28.3.4.4 The numeric punctuation facet [[facet.numpunct]](facet.numpunct#locale.numpunct.general)
#### 28.3.4.4.1 Class template numpunct [[locale.numpunct]](locale.numpunct#general)
#### 28.3.4.4.1.1 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](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L3137)
numpunct<> specifies numeric punctuation[.](#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[.](#1.sentence-2)
[2](#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[.](#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()[.](#2.sentence-2)
For parsing,
if the *digits* portion contains no thousands-separators,
no grouping constraint is applied[.](#2.sentence-3)

View File

@@ -0,0 +1,63 @@
[locale.operators]
# 28 Text processing library [[text]](./#text)
## 28.3 Localization library [[localization]](localization#locale.operators)
### 28.3.3 Locales [[locales]](locales#locale.operators)
#### 28.3.3.1 Class locale [[locale]](locale#operators)
#### 28.3.3.1.5 Operators [locale.operators]
[🔗](#lib:locale,operator==)
`bool operator==(const locale& other) const;
`
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L1070)
*Returns*: true if
both arguments are the same locale, or
one is a copy of the other, or
each has a name and the names are identical;false otherwise[.](#1.sentence-1)
[🔗](#lib:locale,operator())
`template<class charT, class traits, class Allocator>
bool operator()(const basic_string<charT, traits, Allocator>& s1,
const basic_string<charT, traits, Allocator>& s2) const;
`
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L1087)
*Effects*: Compares two strings according to the std::collate<charT> facet[.](#2.sentence-1)
[3](#3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L1091)
*Returns*: use_facet<std::collate<charT>>(*this).compare(s1.data(), s1.data() + s1.size(),
s2.data(), s2.data() + s2.size()) < 0
[4](#4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L1098)
*Remarks*: This member operator template (and therefore locale itself)
meets the requirements for
a comparator predicate template argument ([[algorithms]](algorithms "26Algorithms library")) applied to strings[.](#4.sentence-1)
[5](#5)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L1104)
[*Example [1](#example-1)*:
A vector of strings v can be collated according to collation rules in locale loc simply by ([[alg.sort]](alg.sort "26.8.2Sorting"), [[vector]](vector "23.3.13Class template vector")):
std::sort(v.begin(), v.end(), loc); — *end example*]

View File

@@ -0,0 +1,69 @@
[locale.statics]
# 28 Text processing library [[text]](./#text)
## 28.3 Localization library [[localization]](localization#locale.statics)
### 28.3.3 Locales [[locales]](locales#locale.statics)
#### 28.3.3.1 Class locale [[locale]](locale#statics)
#### 28.3.3.1.6 Static members [locale.statics]
[🔗](#lib:locale,global)
`static locale global(const locale& loc);
`
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L1124)
*Effects*: Sets the global locale to its argument[.](#1.sentence-1)
Causes future calls to the constructor locale() to return a copy of the argument[.](#1.sentence-2)
If the argument has a name, doessetlocale(LC_ALL, loc.name().c_str()); otherwise, the effect on the C locale, if any, isimplementation-defined[.](#1.sentence-3)
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L1136)
*Returns*: The previous value of locale()[.](#2.sentence-1)
[3](#3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L1140)
*Remarks*: No library function other than locale::global() affects the value returned by locale()[.](#3.sentence-1)
[*Note [1](#note-1)*:
See [[c.locales]](c.locales "28.3.5C library locales") for data race considerations
when setlocale is invoked[.](#3.sentence-2)
— *end note*]
[🔗](#lib:locale,classic)
`static const locale& classic();
`
[4](#4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L1156)
The "C" locale[.](#4.sentence-1)
[5](#5)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L1159)
*Returns*: A locale that implements the classic "C" locale semantics,
equivalent to the value locale("C")[.](#5.sentence-1)
[6](#6)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L1164)
*Remarks*: This locale, its facets, and their member functions, do not change with time[.](#6.sentence-1)

22
cppdraft/locale/syn.md Normal file
View File

@@ -0,0 +1,22 @@
[locale.syn]
# 28 Text processing library [[text]](./#text)
## 28.3 Localization library [[localization]](localization#locale.syn)
### 28.3.2 Header <locale> synopsis [locale.syn]
[🔗](#header:%3clocale%3e)
namespace std {// [[locale]](locale "28.3.3.1Class locale"), localeclass locale; template<class Facet> const Facet& use_facet(const locale&); template<class Facet> bool has_facet(const locale&) noexcept; // [[locale.convenience]](locale.convenience "28.3.3.3Convenience interfaces"), convenience interfacestemplate<class charT> bool isspace (charT c, const locale& loc); template<class charT> bool isprint (charT c, const locale& loc); template<class charT> bool iscntrl (charT c, const locale& loc); template<class charT> bool isupper (charT c, const locale& loc); template<class charT> bool islower (charT c, const locale& loc); template<class charT> bool isalpha (charT c, const locale& loc); template<class charT> bool isdigit (charT c, const locale& loc); template<class charT> bool ispunct (charT c, const locale& loc); template<class charT> bool isxdigit(charT c, const locale& loc); template<class charT> bool isalnum (charT c, const locale& loc); template<class charT> bool isgraph (charT c, const locale& loc); template<class charT> bool isblank (charT c, const locale& loc); template<class charT> charT toupper(charT c, const locale& loc); template<class charT> charT tolower(charT c, const locale& loc); // [[category.ctype]](category.ctype "28.3.4.2The ctype category"), ctypeclass ctype_base; template<class charT> class ctype; template<> class ctype<char>; // specializationtemplate<class charT> class ctype_byname; class codecvt_base; template<class internT, class externT, class stateT> class codecvt; template<class internT, class externT, class stateT> class codecvt_byname; // [[category.numeric]](category.numeric "28.3.4.3The numeric category"), numerictemplate<class charT, class InputIterator = istreambuf_iterator<charT>>class num_get; template<class charT, class OutputIterator = ostreambuf_iterator<charT>>class num_put; template<class charT>class numpunct; template<class charT>class numpunct_byname; // [[category.collate]](category.collate "28.3.4.5The collate category"), collationtemplate<class charT> class collate; template<class charT> class collate_byname; // [[category.time]](category.time "28.3.4.6The time category"), date and timeclass time_base; template<class charT, class InputIterator = istreambuf_iterator<charT>>class time_get; template<class charT, class InputIterator = istreambuf_iterator<charT>>class time_get_byname; template<class charT, class OutputIterator = ostreambuf_iterator<charT>>class time_put; template<class charT, class OutputIterator = ostreambuf_iterator<charT>>class time_put_byname; // [[category.monetary]](category.monetary "28.3.4.7The monetary category"), moneyclass money_base; template<class charT, class InputIterator = istreambuf_iterator<charT>>class money_get; template<class charT, class OutputIterator = ostreambuf_iterator<charT>>class money_put; template<class charT, bool Intl = false>class moneypunct; template<class charT, bool Intl = false>class moneypunct_byname; // [[category.messages]](category.messages "28.3.4.8The message retrieval category"), message retrievalclass messages_base; template<class charT> class messages; template<class charT> class messages_byname;}
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L457)
The header [<locale>](#header:%3clocale%3e "28.3.2Header <locale> synopsis[locale.syn]") defines classes and declares functions
that encapsulate and manipulate the information peculiar to a locale[.](#1.sentence-1)[213](#footnote-213 "In this subclause, the type name tm is an incomplete type that is defined in <ctime>.")
[213)](#footnote-213)[213)](#footnoteref-213)
In this subclause, the type name tm is an incomplete type that is defined in [<ctime>](ctime.syn#header:%3cctime%3e "30.15Header <ctime> synopsis[ctime.syn]")[.](#footnote-213.sentence-1)

434
cppdraft/locale/time/get.md Normal file
View File

@@ -0,0 +1,434 @@
[locale.time.get]
# 28 Text processing library [[text]](./#text)
## 28.3 Localization library [[localization]](localization#locale.time.get)
### 28.3.4 Standard locale categories [[locale.categories]](locale.categories#locale.time.get)
#### 28.3.4.6 The time category [[category.time]](category.time#locale.time.get)
#### 28.3.4.6.2 Class template time_get [locale.time.get]
#### [28.3.4.6.2.1](#general) General [[locale.time.get.general]](locale.time.get.general)
[🔗](#lib:time_get)
namespace std {class time_base {public:enum dateorder { no_order, dmy, mdy, ymd, ydm }; }; template<class charT, class InputIterator = istreambuf_iterator<charT>>class time_get : public locale::facet, public time_base {public:using char_type = charT; using iter_type = InputIterator; explicit time_get(size_t refs = 0);
dateorder date_order() const { return do_date_order(); } iter_type get_time(iter_type s, iter_type end, ios_base& f,
ios_base::iostate& err, tm* t) const;
iter_type get_date(iter_type s, iter_type end, ios_base& f,
ios_base::iostate& err, tm* t) const;
iter_type get_weekday(iter_type s, iter_type end, ios_base& f,
ios_base::iostate& err, tm* t) const;
iter_type get_monthname(iter_type s, iter_type end, ios_base& f,
ios_base::iostate& err, tm* t) const;
iter_type get_year(iter_type s, iter_type end, ios_base& f,
ios_base::iostate& err, tm* t) const;
iter_type get(iter_type s, iter_type end, ios_base& f,
ios_base::iostate& err, tm* t, char format, char modifier = 0) const;
iter_type get(iter_type s, iter_type end, ios_base& f,
ios_base::iostate& err, tm* t, const char_type* fmt, const char_type* fmtend) const; static locale::id id; protected:~time_get(); virtual dateorder do_date_order() const; virtual iter_type do_get_time(iter_type s, iter_type end, ios_base&,
ios_base::iostate& err, tm* t) const; virtual iter_type do_get_date(iter_type s, iter_type end, ios_base&,
ios_base::iostate& err, tm* t) const; virtual iter_type do_get_weekday(iter_type s, iter_type end, ios_base&,
ios_base::iostate& err, tm* t) const; virtual iter_type do_get_monthname(iter_type s, iter_type end, ios_base&,
ios_base::iostate& err, tm* t) const; virtual iter_type do_get_year(iter_type s, iter_type end, ios_base&,
ios_base::iostate& err, tm* t) const; virtual iter_type do_get(iter_type s, iter_type end, ios_base& f,
ios_base::iostate& err, tm* t, char format, char modifier) const; };}
[1](#general-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L3585)
time_get is used to parse a character sequence,
extracting components of a time or date into a tm object[.](#general-1.sentence-1)
Each get member parses a format as produced by a corresponding format specifier totime_put<>::put[.](#general-1.sentence-2)
If the sequence being parsed matches the correct format, the corresponding
members of thetm argument are set to the values used to produce the sequence; otherwise
either an error is reported or unspecified values are assigned[.](#general-1.sentence-3)[227](#footnote-227 "In other words, user confirmation is required for reliable parsing of user-entered dates and times, but machine-generated formats can be parsed reliably. This allows parsers to be aggressive about interpreting user variations on standard formats.")
[2](#general-2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L3604)
If the end iterator is reached during parsing by any of theget() member functions, the member setsios_base::eofbit in err[.](#general-2.sentence-1)
[227)](#footnote-227)[227)](#footnoteref-227)
In
other words, user confirmation is required for reliable parsing of
user-entered dates and times, but machine-generated formats can be
parsed reliably[.](#footnote-227.sentence-1)
This allows parsers to be aggressive about
interpreting user variations on standard formats[.](#footnote-227.sentence-2)
#### [28.3.4.6.2.2](#members) Members [[locale.time.get.members]](locale.time.get.members)
[🔗](#lib:time_get,date_order)
`dateorder date_order() const;
`
[1](#members-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L3619)
*Returns*: do_date_order()[.](#members-1.sentence-1)
[🔗](#lib:time_get,get_time)
`iter_type get_time(iter_type s, iter_type end, ios_base& str,
ios_base::iostate& err, tm* t) const;
`
[2](#members-2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L3631)
*Returns*: do_get_time(s, end, str, err, t)[.](#members-2.sentence-1)
[🔗](#lib:time_get,get_date)
`iter_type get_date(iter_type s, iter_type end, ios_base& str,
ios_base::iostate& err, tm* t) const;
`
[3](#members-3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L3643)
*Returns*: do_get_date(s, end, str, err, t)[.](#members-3.sentence-1)
[🔗](#lib:time_get,get_weekday)
`iter_type get_weekday(iter_type s, iter_type end, ios_base& str,
ios_base::iostate& err, tm* t) const;
iter_type get_monthname(iter_type s, iter_type end, ios_base& str,
ios_base::iostate& err, tm* t) const;
`
[4](#members-4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L3658)
*Returns*: do_get_weekday(s, end, str, err, t) ordo_get_monthname(s, end, str, err, t)[.](#members-4.sentence-1)
[🔗](#lib:time_get,get_year)
`iter_type get_year(iter_type s, iter_type end, ios_base& str,
ios_base::iostate& err, tm* t) const;
`
[5](#members-5)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L3672)
*Returns*: do_get_year(s, end, str, err, t)[.](#members-5.sentence-1)
[🔗](#lib:get,time_get)
`iter_type get(iter_type s, iter_type end, ios_base& f, ios_base::iostate& err,
tm* t, char format, char modifier = 0) const;
`
[6](#members-6)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L3684)
*Returns*: do_get(s, end, f, err, t, format, modifier)[.](#members-6.sentence-1)
[🔗](#lib:get,time_get_)
`iter_type get(iter_type s, iter_type end, ios_base& f, ios_base::iostate& err,
tm* t, const char_type* fmt, const char_type* fmtend) const;
`
[7](#members-7)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L3696)
*Preconditions*: [fmt, fmtend) is a valid range[.](#members-7.sentence-1)
[8](#members-8)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L3700)
*Effects*: The function starts by evaluating err = ios_base::goodbit[.](#members-8.sentence-1)
It then enters a loop,
reading zero or more characters from s at each iteration[.](#members-8.sentence-2)
Unless otherwise specified below,
the loop terminates when the first of the following conditions holds:
- [(8.1)](#members-8.1)
The expression fmt == fmtend evaluates to true[.](#members-8.1.sentence-1)
- [(8.2)](#members-8.2)
The expression err == ios_base::goodbit evaluates to false[.](#members-8.2.sentence-1)
- [(8.3)](#members-8.3)
The expression s == end evaluates to true,
in which case
the function evaluates err = ios_base::eofbit | ios_base::failbit[.](#members-8.3.sentence-1)
- [(8.4)](#members-8.4)
The next element of fmt is equal to '%',
optionally followed by a modifier character,
followed by a conversion specifier character, format,
together forming a conversion specification
valid for the POSIX function strptime[.](#members-8.4.sentence-1)
If the number of elements in the range [fmt, fmtend)
is not sufficient to unambiguously determine
whether the conversion specification is complete and valid,
the function evaluates err = ios_base::failbit[.](#members-8.4.sentence-2)
Otherwise,
the function evaluates s = do_get(s, end, f, err, t, format, modifier),
where the value of modifier is '\0' when the optional modifier is absent from the conversion specification[.](#members-8.4.sentence-3)
If err == ios_base::goodbit holds
after the evaluation of the expression,
the function increments fmt to point just past the end of the conversion specification and
continues looping[.](#members-8.4.sentence-4)
- [(8.5)](#members-8.5)
The expression isspace(*fmt, f.getloc()) evaluates to true,
in which case the function first increments fmt untilfmt == fmtend || !isspace(*fmt, f.getloc()) evaluates to true,
then advances s until s == end || !isspace(*s, f.getloc()) is true, and
finally resumes looping[.](#members-8.5.sentence-1)
- [(8.6)](#members-8.6)
The next character read from s matches the element pointed to by fmt in a case-insensitive comparison,
in which case the function evaluates ++fmt, ++s and continues looping[.](#members-8.6.sentence-1)
Otherwise, the function evaluates err = ios_base::failbit[.](#members-8.6.sentence-2)
[9](#members-9)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L3752)
[*Note [1](#members-note-1)*:
The function uses the ctype<charT> facet
installed in f's locale
to determine valid whitespace characters[.](#members-9.sentence-1)
It is unspecified
by what means the function performs case-insensitive comparison or
whether multi-character sequences are considered while doing so[.](#members-9.sentence-2)
— *end note*]
[10](#members-10)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L3762)
*Returns*: s[.](#members-10.sentence-1)
#### [28.3.4.6.2.3](#virtuals) Virtual functions [[locale.time.get.virtuals]](locale.time.get.virtuals)
[🔗](#lib:time_get,do_date_order)
`dateorder do_date_order() const;
`
[1](#virtuals-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L3775)
*Returns*: An enumeration value indicating the preferred order of components
for those date formats that are composed of day, month, and year[.](#virtuals-1.sentence-1)[228](#footnote-228 "This function is intended as a convenience only, for common formats, and can return no_­order in valid locales.")
Returns no_order if the date format specified by 'x' contains other variable components (e.g., Julian day, week number, week day)[.](#virtuals-1.sentence-2)
[🔗](#lib:time_get,do_get_time)
`iter_type do_get_time(iter_type s, iter_type end, ios_base& str,
ios_base::iostate& err, tm* t) const;
`
[2](#virtuals-2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L3794)
*Effects*: Reads characters starting at s until it has extracted those tm members, and
remaining format characters,
used by time_put<>::put to produce the format specified by "%H:%M:%S",
or until it encounters an error or end of sequence[.](#virtuals-2.sentence-1)
[3](#virtuals-3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L3803)
*Returns*: An iterator pointing immediately beyond
the last character recognized as possibly part of a valid time[.](#virtuals-3.sentence-1)
[🔗](#lib:time_get,do_get_date)
`iter_type do_get_date(iter_type s, iter_type end, ios_base& str,
ios_base::iostate& err, tm* t) const;
`
[4](#virtuals-4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L3816)
*Effects*: Reads characters starting at s until it has extracted those tm members and
remaining format characters
used by time_put<>::put to produce one of the following formats,
or until it encounters an error[.](#virtuals-4.sentence-1)
The format depends on the value returned by date_order() as shown in Table [102](#tab:locale.time.get.dogetdate "Table 102: do_­get_­date effects")[.](#virtuals-4.sentence-2)
Table [102](#tab:locale.time.get.dogetdate) — do_get_date effects [[tab:locale.time.get.dogetdate]](./tab:locale.time.get.dogetdate)
| [🔗](#tab:locale.time.get.dogetdate-row-1)<br>**date_order()** | **Format** |
| --- | --- |
| [🔗](#tab:locale.time.get.dogetdate-row-2)<br>no_order | "%m%d%y" |
| [🔗](#tab:locale.time.get.dogetdate-row-3)<br>dmy | "%d%m%y" |
| [🔗](#tab:locale.time.get.dogetdate-row-4)<br>mdy | "%m%d%y" |
| [🔗](#tab:locale.time.get.dogetdate-row-5)<br>ymd | "%y%m%d" |
| [🔗](#tab:locale.time.get.dogetdate-row-6)<br>ydm | "%y%d%m" |
[5](#virtuals-5)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L3836)
An implementation may also accept additionalimplementation-defined formats[.](#virtuals-5.sentence-1)
[6](#virtuals-6)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L3840)
*Returns*: An iterator pointing immediately beyond
the last character recognized as possibly part of a valid date[.](#virtuals-6.sentence-1)
[🔗](#lib:time_get,do_get_weekday)
`iter_type do_get_weekday(iter_type s, iter_type end, ios_base& str,
ios_base::iostate& err, tm* t) const;
iter_type do_get_monthname(iter_type s, iter_type end, ios_base& str,
ios_base::iostate& err, tm* t) const;
`
[7](#virtuals-7)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L3856)
*Effects*: Reads characters starting at s until it has extracted the (perhaps abbreviated) name of a weekday or month[.](#virtuals-7.sentence-1)
If it finds an abbreviation
that is followed by characters that can match a full name,
it continues reading until it matches the full name or fails[.](#virtuals-7.sentence-2)
It sets the appropriate tm member accordingly[.](#virtuals-7.sentence-3)
[8](#virtuals-8)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L3865)
*Returns*: An iterator pointing immediately beyond the last character recognized
as part of a valid name[.](#virtuals-8.sentence-1)
[🔗](#lib:time_get,do_get_year)
`iter_type do_get_year(iter_type s, iter_type end, ios_base& str,
ios_base::iostate& err, tm* t) const;
`
[9](#virtuals-9)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L3878)
*Effects*: Reads characters starting at s until it has extracted an unambiguous year identifier[.](#virtuals-9.sentence-1)
It isimplementation-defined
whether two-digit year numbers are accepted,
and (if so) what century they are assumed to lie in[.](#virtuals-9.sentence-2)
Sets the t->tm_year member accordingly[.](#virtuals-9.sentence-3)
[10](#virtuals-10)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L3888)
*Returns*: An iterator pointing immediately beyond
the last character recognized as part of a valid year identifier[.](#virtuals-10.sentence-1)
[🔗](#lib:do_get,time_get)
`iter_type do_get(iter_type s, iter_type end, ios_base& f,
ios_base::iostate& err, tm* t, char format, char modifier) const;
`
[11](#virtuals-11)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L3901)
*Preconditions*: t points to an object[.](#virtuals-11.sentence-1)
[12](#virtuals-12)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L3905)
*Effects*: The function starts by evaluating err = ios_base::goodbit[.](#virtuals-12.sentence-1)
It then reads characters starting at s until it encounters an error, or
until it has extracted and assigned those tm members, and
any remaining format characters,
corresponding to a conversion specification appropriate for
the POSIX function strptime,
formed by concatenating '%',
the modifier character, when non-NUL, and
the format character[.](#virtuals-12.sentence-2)
When the concatenation fails to yield a complete valid directive
the function leaves the object pointed to by t unchanged and
evaluates err |= ios_base::failbit[.](#virtuals-12.sentence-3)
When s == end evaluates to true after reading a character
the function evaluates err |= ios_base::eofbit[.](#virtuals-12.sentence-4)
[13](#virtuals-13)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L3922)
For complex conversion specifications
such as %c, %x, or %X, or
conversion specifications that involve the optional modifiers E or O,
when the function is unable to unambiguously determine
some or all tm members from the input sequence [s, end),
it evaluates err |= ios_base::eofbit[.](#virtuals-13.sentence-1)
In such cases the values of those tm members are unspecified
and may be outside their valid range[.](#virtuals-13.sentence-2)
[14](#virtuals-14)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L3932)
*Returns*: An iterator pointing immediately beyond
the last character recognized as possibly part of
a valid input sequence for the given format and modifier[.](#virtuals-14.sentence-1)
[15](#virtuals-15)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L3938)
*Remarks*: It is unspecified whether multiple calls to do_get() with the address of the same tm object
will update the current contents of the object or simply overwrite its members[.](#virtuals-15.sentence-1)
Portable programs should zero out the object before invoking the function[.](#virtuals-15.sentence-2)
[228)](#footnote-228)[228)](#footnoteref-228)
This function is intended as a convenience only, for common formats, and
can return no_order in valid locales[.](#footnote-228.sentence-1)

View File

@@ -0,0 +1,15 @@
[locale.time.get.byname]
# 28 Text processing library [[text]](./#text)
## 28.3 Localization library [[localization]](localization#locale.time.get.byname)
### 28.3.4 Standard locale categories [[locale.categories]](locale.categories#locale.time.get.byname)
#### 28.3.4.6 The time category [[category.time]](category.time#locale.time.get.byname)
#### 28.3.4.6.3 Class template time_get_byname [locale.time.get.byname]
[🔗](#lib:time_get_byname)
namespace std {template<class charT, class InputIterator = istreambuf_iterator<charT>>class time_get_byname : public time_get<charT, InputIterator> {public:using dateorder = time_base::dateorder; using iter_type = InputIterator; explicit time_get_byname(const char*, size_t refs = 0); explicit time_get_byname(const string&, size_t refs = 0); protected:~time_get_byname(); };}

View File

@@ -0,0 +1,67 @@
[locale.time.get.general]
# 28 Text processing library [[text]](./#text)
## 28.3 Localization library [[localization]](localization#locale.time.get.general)
### 28.3.4 Standard locale categories [[locale.categories]](locale.categories#locale.time.get.general)
#### 28.3.4.6 The time category [[category.time]](category.time#locale.time.get.general)
#### 28.3.4.6.2 Class template time_get [[locale.time.get]](locale.time.get#general)
#### 28.3.4.6.2.1 General [locale.time.get.general]
[🔗](#lib:time_get)
namespace std {class time_base {public:enum dateorder { no_order, dmy, mdy, ymd, ydm }; }; template<class charT, class InputIterator = istreambuf_iterator<charT>>class time_get : public locale::facet, public time_base {public:using char_type = charT; using iter_type = InputIterator; explicit time_get(size_t refs = 0);
dateorder date_order() const { return do_date_order(); } iter_type get_time(iter_type s, iter_type end, ios_base& f,
ios_base::iostate& err, tm* t) const;
iter_type get_date(iter_type s, iter_type end, ios_base& f,
ios_base::iostate& err, tm* t) const;
iter_type get_weekday(iter_type s, iter_type end, ios_base& f,
ios_base::iostate& err, tm* t) const;
iter_type get_monthname(iter_type s, iter_type end, ios_base& f,
ios_base::iostate& err, tm* t) const;
iter_type get_year(iter_type s, iter_type end, ios_base& f,
ios_base::iostate& err, tm* t) const;
iter_type get(iter_type s, iter_type end, ios_base& f,
ios_base::iostate& err, tm* t, char format, char modifier = 0) const;
iter_type get(iter_type s, iter_type end, ios_base& f,
ios_base::iostate& err, tm* t, const char_type* fmt, const char_type* fmtend) const; static locale::id id; protected:~time_get(); virtual dateorder do_date_order() const; virtual iter_type do_get_time(iter_type s, iter_type end, ios_base&,
ios_base::iostate& err, tm* t) const; virtual iter_type do_get_date(iter_type s, iter_type end, ios_base&,
ios_base::iostate& err, tm* t) const; virtual iter_type do_get_weekday(iter_type s, iter_type end, ios_base&,
ios_base::iostate& err, tm* t) const; virtual iter_type do_get_monthname(iter_type s, iter_type end, ios_base&,
ios_base::iostate& err, tm* t) const; virtual iter_type do_get_year(iter_type s, iter_type end, ios_base&,
ios_base::iostate& err, tm* t) const; virtual iter_type do_get(iter_type s, iter_type end, ios_base& f,
ios_base::iostate& err, tm* t, char format, char modifier) const; };}
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L3585)
time_get is used to parse a character sequence,
extracting components of a time or date into a tm object[.](#1.sentence-1)
Each get member parses a format as produced by a corresponding format specifier totime_put<>::put[.](#1.sentence-2)
If the sequence being parsed matches the correct format, the corresponding
members of thetm argument are set to the values used to produce the sequence; otherwise
either an error is reported or unspecified values are assigned[.](#1.sentence-3)[227](#footnote-227 "In other words, user confirmation is required for reliable parsing of user-entered dates and times, but machine-generated formats can be parsed reliably. This allows parsers to be aggressive about interpreting user variations on standard formats.")
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L3604)
If the end iterator is reached during parsing by any of theget() member functions, the member setsios_base::eofbit in err[.](#2.sentence-1)
[227)](#footnote-227)[227)](#footnoteref-227)
In
other words, user confirmation is required for reliable parsing of
user-entered dates and times, but machine-generated formats can be
parsed reliably[.](#footnote-227.sentence-1)
This allows parsers to be aggressive about
interpreting user variations on standard formats[.](#footnote-227.sentence-2)

View File

@@ -0,0 +1,178 @@
[locale.time.get.members]
# 28 Text processing library [[text]](./#text)
## 28.3 Localization library [[localization]](localization#locale.time.get.members)
### 28.3.4 Standard locale categories [[locale.categories]](locale.categories#locale.time.get.members)
#### 28.3.4.6 The time category [[category.time]](category.time#locale.time.get.members)
#### 28.3.4.6.2 Class template time_get [[locale.time.get]](locale.time.get#members)
#### 28.3.4.6.2.2 Members [locale.time.get.members]
[🔗](#lib:time_get,date_order)
`dateorder date_order() const;
`
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L3619)
*Returns*: do_date_order()[.](#1.sentence-1)
[🔗](#lib:time_get,get_time)
`iter_type get_time(iter_type s, iter_type end, ios_base& str,
ios_base::iostate& err, tm* t) const;
`
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L3631)
*Returns*: do_get_time(s, end, str, err, t)[.](#2.sentence-1)
[🔗](#lib:time_get,get_date)
`iter_type get_date(iter_type s, iter_type end, ios_base& str,
ios_base::iostate& err, tm* t) const;
`
[3](#3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L3643)
*Returns*: do_get_date(s, end, str, err, t)[.](#3.sentence-1)
[🔗](#lib:time_get,get_weekday)
`iter_type get_weekday(iter_type s, iter_type end, ios_base& str,
ios_base::iostate& err, tm* t) const;
iter_type get_monthname(iter_type s, iter_type end, ios_base& str,
ios_base::iostate& err, tm* t) const;
`
[4](#4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L3658)
*Returns*: do_get_weekday(s, end, str, err, t) ordo_get_monthname(s, end, str, err, t)[.](#4.sentence-1)
[🔗](#lib:time_get,get_year)
`iter_type get_year(iter_type s, iter_type end, ios_base& str,
ios_base::iostate& err, tm* t) const;
`
[5](#5)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L3672)
*Returns*: do_get_year(s, end, str, err, t)[.](#5.sentence-1)
[🔗](#lib:get,time_get)
`iter_type get(iter_type s, iter_type end, ios_base& f, ios_base::iostate& err,
tm* t, char format, char modifier = 0) const;
`
[6](#6)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L3684)
*Returns*: do_get(s, end, f, err, t, format, modifier)[.](#6.sentence-1)
[🔗](#lib:get,time_get_)
`iter_type get(iter_type s, iter_type end, ios_base& f, ios_base::iostate& err,
tm* t, const char_type* fmt, const char_type* fmtend) const;
`
[7](#7)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L3696)
*Preconditions*: [fmt, fmtend) is a valid range[.](#7.sentence-1)
[8](#8)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L3700)
*Effects*: The function starts by evaluating err = ios_base::goodbit[.](#8.sentence-1)
It then enters a loop,
reading zero or more characters from s at each iteration[.](#8.sentence-2)
Unless otherwise specified below,
the loop terminates when the first of the following conditions holds:
- [(8.1)](#8.1)
The expression fmt == fmtend evaluates to true[.](#8.1.sentence-1)
- [(8.2)](#8.2)
The expression err == ios_base::goodbit evaluates to false[.](#8.2.sentence-1)
- [(8.3)](#8.3)
The expression s == end evaluates to true,
in which case
the function evaluates err = ios_base::eofbit | ios_base::failbit[.](#8.3.sentence-1)
- [(8.4)](#8.4)
The next element of fmt is equal to '%',
optionally followed by a modifier character,
followed by a conversion specifier character, format,
together forming a conversion specification
valid for the POSIX function strptime[.](#8.4.sentence-1)
If the number of elements in the range [fmt, fmtend)
is not sufficient to unambiguously determine
whether the conversion specification is complete and valid,
the function evaluates err = ios_base::failbit[.](#8.4.sentence-2)
Otherwise,
the function evaluates s = do_get(s, end, f, err, t, format, modifier),
where the value of modifier is '\0' when the optional modifier is absent from the conversion specification[.](#8.4.sentence-3)
If err == ios_base::goodbit holds
after the evaluation of the expression,
the function increments fmt to point just past the end of the conversion specification and
continues looping[.](#8.4.sentence-4)
- [(8.5)](#8.5)
The expression isspace(*fmt, f.getloc()) evaluates to true,
in which case the function first increments fmt untilfmt == fmtend || !isspace(*fmt, f.getloc()) evaluates to true,
then advances s until s == end || !isspace(*s, f.getloc()) is true, and
finally resumes looping[.](#8.5.sentence-1)
- [(8.6)](#8.6)
The next character read from s matches the element pointed to by fmt in a case-insensitive comparison,
in which case the function evaluates ++fmt, ++s and continues looping[.](#8.6.sentence-1)
Otherwise, the function evaluates err = ios_base::failbit[.](#8.6.sentence-2)
[9](#9)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L3752)
[*Note [1](#note-1)*:
The function uses the ctype<charT> facet
installed in f's locale
to determine valid whitespace characters[.](#9.sentence-1)
It is unspecified
by what means the function performs case-insensitive comparison or
whether multi-character sequences are considered while doing so[.](#9.sentence-2)
— *end note*]
[10](#10)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L3762)
*Returns*: s[.](#10.sentence-1)

View File

@@ -0,0 +1,211 @@
[locale.time.get.virtuals]
# 28 Text processing library [[text]](./#text)
## 28.3 Localization library [[localization]](localization#locale.time.get.virtuals)
### 28.3.4 Standard locale categories [[locale.categories]](locale.categories#locale.time.get.virtuals)
#### 28.3.4.6 The time category [[category.time]](category.time#locale.time.get.virtuals)
#### 28.3.4.6.2 Class template time_get [[locale.time.get]](locale.time.get#virtuals)
#### 28.3.4.6.2.3 Virtual functions [locale.time.get.virtuals]
[🔗](#lib:time_get,do_date_order)
`dateorder do_date_order() const;
`
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L3775)
*Returns*: An enumeration value indicating the preferred order of components
for those date formats that are composed of day, month, and year[.](#1.sentence-1)[228](#footnote-228 "This function is intended as a convenience only, for common formats, and can return no_­order in valid locales.")
Returns no_order if the date format specified by 'x' contains other variable components (e.g., Julian day, week number, week day)[.](#1.sentence-2)
[🔗](#lib:time_get,do_get_time)
`iter_type do_get_time(iter_type s, iter_type end, ios_base& str,
ios_base::iostate& err, tm* t) const;
`
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L3794)
*Effects*: Reads characters starting at s until it has extracted those tm members, and
remaining format characters,
used by time_put<>::put to produce the format specified by "%H:%M:%S",
or until it encounters an error or end of sequence[.](#2.sentence-1)
[3](#3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L3803)
*Returns*: An iterator pointing immediately beyond
the last character recognized as possibly part of a valid time[.](#3.sentence-1)
[🔗](#lib:time_get,do_get_date)
`iter_type do_get_date(iter_type s, iter_type end, ios_base& str,
ios_base::iostate& err, tm* t) const;
`
[4](#4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L3816)
*Effects*: Reads characters starting at s until it has extracted those tm members and
remaining format characters
used by time_put<>::put to produce one of the following formats,
or until it encounters an error[.](#4.sentence-1)
The format depends on the value returned by date_order() as shown in Table [102](#tab:locale.time.get.dogetdate "Table 102: do_­get_­date effects")[.](#4.sentence-2)
Table [102](#tab:locale.time.get.dogetdate) — do_get_date effects [[tab:locale.time.get.dogetdate]](./tab:locale.time.get.dogetdate)
| [🔗](#tab:locale.time.get.dogetdate-row-1)<br>**date_order()** | **Format** |
| --- | --- |
| [🔗](#tab:locale.time.get.dogetdate-row-2)<br>no_order | "%m%d%y" |
| [🔗](#tab:locale.time.get.dogetdate-row-3)<br>dmy | "%d%m%y" |
| [🔗](#tab:locale.time.get.dogetdate-row-4)<br>mdy | "%m%d%y" |
| [🔗](#tab:locale.time.get.dogetdate-row-5)<br>ymd | "%y%m%d" |
| [🔗](#tab:locale.time.get.dogetdate-row-6)<br>ydm | "%y%d%m" |
[5](#5)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L3836)
An implementation may also accept additionalimplementation-defined formats[.](#5.sentence-1)
[6](#6)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L3840)
*Returns*: An iterator pointing immediately beyond
the last character recognized as possibly part of a valid date[.](#6.sentence-1)
[🔗](#lib:time_get,do_get_weekday)
`iter_type do_get_weekday(iter_type s, iter_type end, ios_base& str,
ios_base::iostate& err, tm* t) const;
iter_type do_get_monthname(iter_type s, iter_type end, ios_base& str,
ios_base::iostate& err, tm* t) const;
`
[7](#7)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L3856)
*Effects*: Reads characters starting at s until it has extracted the (perhaps abbreviated) name of a weekday or month[.](#7.sentence-1)
If it finds an abbreviation
that is followed by characters that can match a full name,
it continues reading until it matches the full name or fails[.](#7.sentence-2)
It sets the appropriate tm member accordingly[.](#7.sentence-3)
[8](#8)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L3865)
*Returns*: An iterator pointing immediately beyond the last character recognized
as part of a valid name[.](#8.sentence-1)
[🔗](#lib:time_get,do_get_year)
`iter_type do_get_year(iter_type s, iter_type end, ios_base& str,
ios_base::iostate& err, tm* t) const;
`
[9](#9)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L3878)
*Effects*: Reads characters starting at s until it has extracted an unambiguous year identifier[.](#9.sentence-1)
It isimplementation-defined
whether two-digit year numbers are accepted,
and (if so) what century they are assumed to lie in[.](#9.sentence-2)
Sets the t->tm_year member accordingly[.](#9.sentence-3)
[10](#10)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L3888)
*Returns*: An iterator pointing immediately beyond
the last character recognized as part of a valid year identifier[.](#10.sentence-1)
[🔗](#lib:do_get,time_get)
`iter_type do_get(iter_type s, iter_type end, ios_base& f,
ios_base::iostate& err, tm* t, char format, char modifier) const;
`
[11](#11)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L3901)
*Preconditions*: t points to an object[.](#11.sentence-1)
[12](#12)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L3905)
*Effects*: The function starts by evaluating err = ios_base::goodbit[.](#12.sentence-1)
It then reads characters starting at s until it encounters an error, or
until it has extracted and assigned those tm members, and
any remaining format characters,
corresponding to a conversion specification appropriate for
the POSIX function strptime,
formed by concatenating '%',
the modifier character, when non-NUL, and
the format character[.](#12.sentence-2)
When the concatenation fails to yield a complete valid directive
the function leaves the object pointed to by t unchanged and
evaluates err |= ios_base::failbit[.](#12.sentence-3)
When s == end evaluates to true after reading a character
the function evaluates err |= ios_base::eofbit[.](#12.sentence-4)
[13](#13)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L3922)
For complex conversion specifications
such as %c, %x, or %X, or
conversion specifications that involve the optional modifiers E or O,
when the function is unable to unambiguously determine
some or all tm members from the input sequence [s, end),
it evaluates err |= ios_base::eofbit[.](#13.sentence-1)
In such cases the values of those tm members are unspecified
and may be outside their valid range[.](#13.sentence-2)
[14](#14)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L3932)
*Returns*: An iterator pointing immediately beyond
the last character recognized as possibly part of
a valid input sequence for the given format and modifier[.](#14.sentence-1)
[15](#15)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L3938)
*Remarks*: It is unspecified whether multiple calls to do_get() with the address of the same tm object
will update the current contents of the object or simply overwrite its members[.](#15.sentence-1)
Portable programs should zero out the object before invoking the function[.](#15.sentence-2)
[228)](#footnote-228)[228)](#footnoteref-228)
This function is intended as a convenience only, for common formats, and
can return no_order in valid locales[.](#footnote-228.sentence-1)

131
cppdraft/locale/time/put.md Normal file
View File

@@ -0,0 +1,131 @@
[locale.time.put]
# 28 Text processing library [[text]](./#text)
## 28.3 Localization library [[localization]](localization#locale.time.put)
### 28.3.4 Standard locale categories [[locale.categories]](locale.categories#locale.time.put)
#### 28.3.4.6 The time category [[category.time]](category.time#locale.time.put)
#### 28.3.4.6.4 Class template time_put [locale.time.put]
#### [28.3.4.6.4.1](#general) General [[locale.time.put.general]](locale.time.put.general)
[🔗](#lib:time_put)
namespace std {template<class charT, class OutputIterator = ostreambuf_iterator<charT>>class time_put : public locale::facet {public:using char_type = charT; using iter_type = OutputIterator; explicit time_put(size_t refs = 0); // the following is implemented in terms of other member functions. iter_type put(iter_type s, ios_base& f, char_type fill, const tm* tmb, const charT* pattern, const charT* pat_end) const;
iter_type put(iter_type s, ios_base& f, char_type fill, const tm* tmb, char format, char modifier = 0) const; static locale::id id; protected:~time_put(); virtual iter_type do_put(iter_type s, ios_base&, char_type, const tm* t, char format, char modifier) const; };}
#### [28.3.4.6.4.2](#members) Members [[locale.time.put.members]](locale.time.put.members)
[🔗](#lib:time_put,put)
`iter_type put(iter_type s, ios_base& str, char_type fill, const tm* t,
const charT* pattern, const charT* pat_end) const;
iter_type put(iter_type s, ios_base& str, char_type fill, const tm* t,
char format, char modifier = 0) const;
`
[1](#members-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L4008)
*Effects*: The first form steps through the sequence
from pattern to pat_end,
identifying characters that are part of a format sequence[.](#members-1.sentence-1)
Each character that is not part of a format sequence
is written to s immediately, and
each format sequence, as it is identified, results in a call to do_put;
thus, format elements and other characters are interleaved in the output
in the order in which they appear in the pattern[.](#members-1.sentence-2)
Format sequences are identified by converting each character c to
a char value as if by ct.narrow(c, 0),
where ct is a reference to ctype<charT> obtained from str.getloc()[.](#members-1.sentence-3)
The first character of each sequence is equal to '%',
followed by an optional modifier character mod and a format specifier character spec as defined for the function strftime[.](#members-1.sentence-4)
If no modifier character is present, mod is zero[.](#members-1.sentence-5)
For each valid format sequence identified,
calls do_put(s, str, fill, t, spec, mod)[.](#members-1.sentence-6)
[2](#members-2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L4030)
The second form calls do_put(s, str, fill, t, format, modifier)[.](#members-2.sentence-1)
[3](#members-3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L4033)
[*Note [1](#members-note-1)*:
The fill argument can be used
in the implementation-defined formats or by derivations[.](#members-3.sentence-1)
A space character is a reasonable default for this argument[.](#members-3.sentence-2)
— *end note*]
[4](#members-4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L4040)
*Returns*: An iterator pointing immediately after the last character produced[.](#members-4.sentence-1)
#### [28.3.4.6.4.3](#virtuals) Virtual functions [[locale.time.put.virtuals]](locale.time.put.virtuals)
[🔗](#lib:time_put,do_put)
`iter_type do_put(iter_type s, ios_base&, char_type fill, const tm* t,
char format, char modifier) const;
`
[1](#virtuals-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L4054)
*Effects*: Formats the contents of the parameter t into characters placed on the output sequence s[.](#virtuals-1.sentence-1)
Formatting is controlled by the parameters format and modifier,
interpreted identically as the format specifiers
in the string argument to the standard library functionstrftime(),
except that the sequence of characters produced for those specifiers
that are described as depending on the C locale
are insteadimplementation-defined[.](#virtuals-1.sentence-2)
[*Note [1](#virtuals-note-1)*:
Interpretation of the modifier argument is implementation-defined[.](#virtuals-1.sentence-3)
— *end note*]
[2](#virtuals-2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L4072)
*Returns*: An iterator pointing immediately after the last character produced[.](#virtuals-2.sentence-1)
[*Note [2](#virtuals-note-2)*:
The fill argument can be used
in the implementation-defined formats or by derivations[.](#virtuals-2.sentence-2)
A space character is a reasonable default for this argument[.](#virtuals-2.sentence-3)
— *end note*]
[3](#virtuals-3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L4081)
*Recommended practice*: Interpretation of the modifier should follow POSIX conventions[.](#virtuals-3.sentence-1)
Implementations should refer to other standards such as POSIX
for a specification of the character sequences produced for
those specifiers described as depending on the C locale[.](#virtuals-3.sentence-2)

View File

@@ -0,0 +1,15 @@
[locale.time.put.byname]
# 28 Text processing library [[text]](./#text)
## 28.3 Localization library [[localization]](localization#locale.time.put.byname)
### 28.3.4 Standard locale categories [[locale.categories]](locale.categories#locale.time.put.byname)
#### 28.3.4.6 The time category [[category.time]](category.time#locale.time.put.byname)
#### 28.3.4.6.5 Class template time_put_byname [locale.time.put.byname]
[🔗](#lib:time_put_byname)
namespace std {template<class charT, class OutputIterator = ostreambuf_iterator<charT>>class time_put_byname : public time_put<charT, OutputIterator> {public:using char_type = charT; using iter_type = OutputIterator; explicit time_put_byname(const char*, size_t refs = 0); explicit time_put_byname(const string&, size_t refs = 0); protected:~time_put_byname(); };}

View File

@@ -0,0 +1,18 @@
[locale.time.put.general]
# 28 Text processing library [[text]](./#text)
## 28.3 Localization library [[localization]](localization#locale.time.put.general)
### 28.3.4 Standard locale categories [[locale.categories]](locale.categories#locale.time.put.general)
#### 28.3.4.6 The time category [[category.time]](category.time#locale.time.put.general)
#### 28.3.4.6.4 Class template time_put [[locale.time.put]](locale.time.put#general)
#### 28.3.4.6.4.1 General [locale.time.put.general]
[🔗](#lib:time_put)
namespace std {template<class charT, class OutputIterator = ostreambuf_iterator<charT>>class time_put : public locale::facet {public:using char_type = charT; using iter_type = OutputIterator; explicit time_put(size_t refs = 0); // the following is implemented in terms of other member functions. iter_type put(iter_type s, ios_base& f, char_type fill, const tm* tmb, const charT* pattern, const charT* pat_end) const;
iter_type put(iter_type s, ios_base& f, char_type fill, const tm* tmb, char format, char modifier = 0) const; static locale::id id; protected:~time_put(); virtual iter_type do_put(iter_type s, ios_base&, char_type, const tm* t, char format, char modifier) const; };}

View File

@@ -0,0 +1,72 @@
[locale.time.put.members]
# 28 Text processing library [[text]](./#text)
## 28.3 Localization library [[localization]](localization#locale.time.put.members)
### 28.3.4 Standard locale categories [[locale.categories]](locale.categories#locale.time.put.members)
#### 28.3.4.6 The time category [[category.time]](category.time#locale.time.put.members)
#### 28.3.4.6.4 Class template time_put [[locale.time.put]](locale.time.put#members)
#### 28.3.4.6.4.2 Members [locale.time.put.members]
[🔗](#lib:time_put,put)
`iter_type put(iter_type s, ios_base& str, char_type fill, const tm* t,
const charT* pattern, const charT* pat_end) const;
iter_type put(iter_type s, ios_base& str, char_type fill, const tm* t,
char format, char modifier = 0) const;
`
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L4008)
*Effects*: The first form steps through the sequence
from pattern to pat_end,
identifying characters that are part of a format sequence[.](#1.sentence-1)
Each character that is not part of a format sequence
is written to s immediately, and
each format sequence, as it is identified, results in a call to do_put;
thus, format elements and other characters are interleaved in the output
in the order in which they appear in the pattern[.](#1.sentence-2)
Format sequences are identified by converting each character c to
a char value as if by ct.narrow(c, 0),
where ct is a reference to ctype<charT> obtained from str.getloc()[.](#1.sentence-3)
The first character of each sequence is equal to '%',
followed by an optional modifier character mod and a format specifier character spec as defined for the function strftime[.](#1.sentence-4)
If no modifier character is present, mod is zero[.](#1.sentence-5)
For each valid format sequence identified,
calls do_put(s, str, fill, t, spec, mod)[.](#1.sentence-6)
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L4030)
The second form calls do_put(s, str, fill, t, format, modifier)[.](#2.sentence-1)
[3](#3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L4033)
[*Note [1](#note-1)*:
The fill argument can be used
in the implementation-defined formats or by derivations[.](#3.sentence-1)
A space character is a reasonable default for this argument[.](#3.sentence-2)
— *end note*]
[4](#4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L4040)
*Returns*: An iterator pointing immediately after the last character produced[.](#4.sentence-1)

View File

@@ -0,0 +1,63 @@
[locale.time.put.virtuals]
# 28 Text processing library [[text]](./#text)
## 28.3 Localization library [[localization]](localization#locale.time.put.virtuals)
### 28.3.4 Standard locale categories [[locale.categories]](locale.categories#locale.time.put.virtuals)
#### 28.3.4.6 The time category [[category.time]](category.time#locale.time.put.virtuals)
#### 28.3.4.6.4 Class template time_put [[locale.time.put]](locale.time.put#virtuals)
#### 28.3.4.6.4.3 Virtual functions [locale.time.put.virtuals]
[🔗](#lib:time_put,do_put)
`iter_type do_put(iter_type s, ios_base&, char_type fill, const tm* t,
char format, char modifier) const;
`
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L4054)
*Effects*: Formats the contents of the parameter t into characters placed on the output sequence s[.](#1.sentence-1)
Formatting is controlled by the parameters format and modifier,
interpreted identically as the format specifiers
in the string argument to the standard library functionstrftime(),
except that the sequence of characters produced for those specifiers
that are described as depending on the C locale
are insteadimplementation-defined[.](#1.sentence-2)
[*Note [1](#note-1)*:
Interpretation of the modifier argument is implementation-defined[.](#1.sentence-3)
— *end note*]
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L4072)
*Returns*: An iterator pointing immediately after the last character produced[.](#2.sentence-1)
[*Note [2](#note-2)*:
The fill argument can be used
in the implementation-defined formats or by derivations[.](#2.sentence-2)
A space character is a reasonable default for this argument[.](#2.sentence-3)
— *end note*]
[3](#3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L4081)
*Recommended practice*: Interpretation of the modifier should follow POSIX conventions[.](#3.sentence-1)
Implementations should refer to other standards such as POSIX
for a specification of the character sequences produced for
those specifiers described as depending on the C locale[.](#3.sentence-2)

257
cppdraft/locale/types.md Normal file
View File

@@ -0,0 +1,257 @@
[locale.types]
# 28 Text processing library [[text]](./#text)
## 28.3 Localization library [[localization]](localization#locale.types)
### 28.3.3 Locales [[locales]](locales#locale.types)
#### 28.3.3.1 Class locale [[locale]](locale#types)
#### 28.3.3.1.2 Types [locale.types]
#### [28.3.3.1.2.1](#locale.category) Type locale::category [[locale.category]](locale.category)
[🔗](#lib:locale,category)
`using category = int;
`
[1](#locale.category-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L633)
*Valid* category values
include the locale member bitmask elementscollate,ctype,monetary,numeric,time,
andmessages,
each of which represents a single locale category[.](#locale.category-1.sentence-1)
In addition, locale member bitmask constant none is defined as zero and represents no category[.](#locale.category-1.sentence-2)
And locale member bitmask constant all is defined such that the expression(collate | ctype | monetary | numeric | time | messages | all) == all is true,
and represents the union of all categories[.](#locale.category-1.sentence-3)
Further, the expression (X | Y),
where X and Y each represent a single category,
represents the union of the two categories[.](#locale.category-1.sentence-4)
[2](#locale.category-2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L657)
locale member functions
expecting a category argument
require one of the category values defined above, or
the union of two or more such values[.](#locale.category-2.sentence-1)
Such a category value identifies a set of locale categories[.](#locale.category-2.sentence-2)
Each locale category, in turn, identifies a set of locale facets,
including at least those shown in Table [91](#tab:locale.category.facets "Table 91: Locale category facets")[.](#locale.category-2.sentence-3)
Table [91](#tab:locale.category.facets) — Locale category facets [[tab:locale.category.facets]](./tab:locale.category.facets)
| [🔗](#tab:locale.category.facets-row-1)<br>**Category** | **Includes facets** |
| --- | --- |
| [🔗](#tab:locale.category.facets-row-2)<br>collate | collate<char>, collate<wchar_t> |
| [🔗](#tab:locale.category.facets-row-3)<br>ctype | ctype<char>, ctype<wchar_t> |
| [🔗](#tab:locale.category.facets-row-4) | codecvt<char, char, mbstate_t> |
| [🔗](#tab:locale.category.facets-row-5) | codecvt<wchar_t, char, mbstate_t> |
| [🔗](#tab:locale.category.facets-row-6)<br>monetary | moneypunct<char>, moneypunct<wchar_t> |
| [🔗](#tab:locale.category.facets-row-7) | moneypunct<char, true>, moneypunct<wchar_t, true> |
| [🔗](#tab:locale.category.facets-row-8) | money_get<char>, money_get<wchar_t> |
| [🔗](#tab:locale.category.facets-row-9) | money_put<char>, money_put<wchar_t> |
| [🔗](#tab:locale.category.facets-row-10)<br>numeric | numpunct<char>, numpunct<wchar_t> |
| [🔗](#tab:locale.category.facets-row-11) | num_get<char>, num_get<wchar_t> |
| [🔗](#tab:locale.category.facets-row-12) | num_put<char>, num_put<wchar_t> |
| [🔗](#tab:locale.category.facets-row-13)<br>time | time_get<char>, time_get<wchar_t> |
| [🔗](#tab:locale.category.facets-row-14) | time_put<char>, time_put<wchar_t> |
| [🔗](#tab:locale.category.facets-row-15)<br>messages | messages<char>, messages<wchar_t> |
[3](#locale.category-3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L686)
For any locale loc either constructed, or returned by locale::classic(),
and any facet Facet shown in Table [91](#tab:locale.category.facets "Table 91: Locale category facets"),has_facet<Facet>(loc) is true[.](#locale.category-3.sentence-1)
Each locale member function
which takes a locale::category argument
operates on the corresponding set of facets[.](#locale.category-3.sentence-2)
[4](#locale.category-4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L695)
An implementation is required to provide those specializations
for facet templates identified as members of a category, and
for those shown in Table [92](#tab:locale.spec "Table 92: Required specializations")[.](#locale.category-4.sentence-1)
Table [92](#tab:locale.spec) — Required specializations [[tab:locale.spec]](./tab:locale.spec)
| [🔗](#tab:locale.spec-row-1)<br>**Category** | **Includes facets** |
| --- | --- |
| [🔗](#tab:locale.spec-row-2)<br>collate | collate_byname<char>, collate_byname<wchar_t> |
| [🔗](#tab:locale.spec-row-3)<br>ctype | ctype_byname<char>, ctype_byname<wchar_t> |
| [🔗](#tab:locale.spec-row-4) | codecvt_byname<char, char, mbstate_t> |
| [🔗](#tab:locale.spec-row-5) | codecvt_byname<wchar_t, char, mbstate_t> |
| [🔗](#tab:locale.spec-row-6)<br>monetary | moneypunct_byname<char, International> |
| [🔗](#tab:locale.spec-row-7) | moneypunct_byname<wchar_t, International> |
| [🔗](#tab:locale.spec-row-8) | money_get<C, InputIterator> |
| [🔗](#tab:locale.spec-row-9) | money_put<C, OutputIterator> |
| [🔗](#tab:locale.spec-row-10)<br>numeric | numpunct_byname<char>, numpunct_byname<wchar_t> |
| [🔗](#tab:locale.spec-row-11) | num_get<C, InputIterator>, num_put<C, OutputIterator> |
| [🔗](#tab:locale.spec-row-12)<br>time | time_get<char, InputIterator> |
| [🔗](#tab:locale.spec-row-13) | time_get_byname<char, InputIterator> |
| [🔗](#tab:locale.spec-row-14) | time_get<wchar_t, InputIterator> |
| [🔗](#tab:locale.spec-row-15) | time_get_byname<wchar_t, InputIterator> |
| [🔗](#tab:locale.spec-row-16) | time_put<char, OutputIterator> |
| [🔗](#tab:locale.spec-row-17) | time_put_byname<char, OutputIterator> |
| [🔗](#tab:locale.spec-row-18) | time_put<wchar_t, OutputIterator> |
| [🔗](#tab:locale.spec-row-19) | time_put_byname<wchar_t, OutputIterator> |
| [🔗](#tab:locale.spec-row-20)<br>messages | messages_byname<char>, messages_byname<wchar_t> |
[5](#locale.category-5)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L726)
The provided implementation of members of
facets num_get<charT> and num_put<charT> calls use_facet<F>(l) only for facet F of
types numpunct<charT> and ctype<charT>,
and for locale l the value obtained by calling member getloc() on the ios_base& argument to these functions[.](#locale.category-5.sentence-1)
[6](#locale.category-6)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L734)
In declarations of facets,
a template parameter with name InputIterator or OutputIterator indicates the set of all possible specializations on parameters that meet the*Cpp17InputIterator* requirements or*Cpp17OutputIterator* requirements,
respectively ([[iterator.requirements]](iterator.requirements "24.3Iterator requirements"))[.](#locale.category-6.sentence-1)
A template parameter with name C represents
the set of types containing char, wchar_t, and any otherimplementation-defined
character container types ([[defns.character.container]](defns.character.container "3.10character container type"))
that meet the requirements for a character
on which any of the iostream components can be instantiated[.](#locale.category-6.sentence-2)
A template parameter with name International represents the set of all possible specializations on a bool parameter[.](#locale.category-6.sentence-3)
#### [28.3.3.1.2.2](#locale.facet) Class locale::facet [[locale.facet]](locale.facet)
[🔗](#lib:locale,facet)
namespace std {class locale::facet {protected:explicit facet(size_t refs = 0); virtual ~facet();
facet(const facet&) = delete; void operator=(const facet&) = delete; };}
[1](#locale.facet-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L766)
Class facet is the base class for locale feature sets[.](#locale.facet-1.sentence-1)
A class is a [*facet*](#def:facet "28.3.3.1.2.2Class locale::facet[locale.facet]") if it is publicly derived from another facet, or
if it is a class derived from locale::facet and
contains a publicly accessible declaration as follows:[215](#footnote-215 "This is a complete list of requirements; there are no other requirements. Thus, a facet class need not have a public copy constructor, assignment, default constructor, destructor, etc.")static ::std::locale::id id;
[2](#locale.facet-2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L781)
Template parameters in this Clause
which are required to be facets
are those named Facet in declarations[.](#locale.facet-2.sentence-1)
A program that passes
a type that is *not* a facet, or
a type that refers to a volatile-qualified facet,
as an (explicit or deduced) template parameter to
a locale function expecting a facet,
is ill-formed[.](#locale.facet-2.sentence-2)
A const-qualified facet is a valid template argument to
any locale function that expects a Facet template parameter[.](#locale.facet-2.sentence-3)
[3](#locale.facet-3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L794)
The refs argument to the constructor is used for lifetime management[.](#locale.facet-3.sentence-1)
For refs == 0,
the implementation performs delete static_cast<locale::facet*>(f) (where f is a pointer to the facet)
when the last locale object containing the facet is destroyed;
for refs == 1, the implementation never destroys the facet[.](#locale.facet-3.sentence-2)
[4](#locale.facet-4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L802)
Constructors of all facets defined in this Clause
take such an argument and pass it along to
their facet base class constructor[.](#locale.facet-4.sentence-1)
All one-argument constructors defined in this Clause are explicit,
preventing their participation in implicit conversions[.](#locale.facet-4.sentence-2)
[5](#locale.facet-5)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L809)
For some standard facets a standard “…_byname” class,
derived from it, implements the virtual function semantics
equivalent to that facet of the locale
constructed by locale(const char*) with the same name[.](#locale.facet-5.sentence-1)
Each such facet provides a constructor that takes
a const char* argument, which names the locale, and
a refs argument, which is passed to the base class constructor[.](#locale.facet-5.sentence-2)
Each such facet also provides a constructor that takes
a string argument str and
a refs argument,
which has the same effect as calling the first constructor
with the two arguments str.c_str() and refs[.](#locale.facet-5.sentence-3)
If there is no “…_byname” version of a facet,
the base class implements named locale semantics itself
by reference to other facets[.](#locale.facet-5.sentence-4)
[215)](#footnote-215)[215)](#footnoteref-215)
This is a complete list of requirements; there are no other requirements[.](#footnote-215.sentence-1)
Thus, a facet class need not have a public
copy constructor, assignment, default constructor, destructor, etc[.](#footnote-215.sentence-2)
#### [28.3.3.1.2.3](#locale.id) Class locale::id [[locale.id]](locale.id)
[🔗](#lib:locale,id)
namespace std {class locale::id {public: id(); void operator=(const id&) = delete;
id(const id&) = delete; };}
[1](#locale.id-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L840)
The class locale::id provides
identification of a locale facet interface,
used as an index for lookup and to encapsulate initialization[.](#locale.id-1.sentence-1)
[2](#locale.id-2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L845)
[*Note [1](#locale.id-note-1)*:
Because facets are used by iostreams,
potentially while static constructors are running,
their initialization cannot depend on programmed static initialization[.](#locale.id-2.sentence-1)
One initialization strategy is for locale to initialize each facet's id member
the first time an instance of the facet is installed into a locale[.](#locale.id-2.sentence-2)
This depends only on static storage being zero
before constructors run ([[basic.start.static]](basic.start.static "6.10.3.2Static initialization"))[.](#locale.id-2.sentence-3)
— *end note*]