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

99 lines
3.8 KiB
Markdown
Raw 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.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)