Files
2025-10-25 03:02:53 +03:00

138 lines
7.1 KiB
Markdown
Raw Permalink Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

[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)