[locale.facet] (original) (raw)
28 Localization library [localization]
28.3 Locales [locales]
28.3.1 Class locale [locale]
28.3.1.1 Types [locale.types]
28.3.1.1.2 Class locale::facet [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; }; }
Class facet is the base class for locale feature sets.
A class is a facetif 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:258
static ::std::locale::id id;
Template parameters in this Clause which are required to be facets are those namedFacetin declarations.
A program that passes a type that isnota 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.
A const-qualified facet is a valid template argument to any locale function that expects aFacet template parameter.
The refsargument to the constructor is used for lifetime management.
Forrefs == 0, the implementation performsdelete static_cast<locale::facet*>(f)(wherefis a pointer to the facet) when the lastlocaleobject containing the facet is destroyed; forrefs == 1, the implementation never destroys the facet.
Constructors of all facets defined in this Clause take such an argument and pass it along to theirfacetbase class constructor.
All one-argument constructors defined in this Clause areexplicit, preventing their participation in automatic conversions.
For some standard facets a standard “…_byname” class, derived from it, implements the virtual function semantics equivalent to that facet of the locale constructed bylocale(const char*)with the same name.
Each such facet provides a constructor that takes aconst char*argument, which names the locale, and a refsargument, which is passed to the base class constructor.
Each such facet also provides a constructor that takes astring argument str and a refsargument, which has the same effect as calling the first constructor with the two arguments str.c_str() and refs.
If there is no “…_byname” version of a facet, the base class implements named locale semantics itself by reference to other facets.