.TH "std::locale" 3cxx "Fri May 28 2021" "libstdc++" \" -*- nroff -*- .ad l .nh .SH NAME std::locale \- Container class for localization functionality\&. .SH SYNOPSIS .br .PP .SS "Classes" .in +1c .ti -1c .RI "class \fBfacet\fP" .br .RI "Localization functionality base class\&. " .ti -1c .RI "class \fBid\fP" .br .RI "Facet ID class\&. " .in -1c .SS "Public Types" .in +1c .ti -1c .RI "typedef int \fBcategory\fP" .br .RI "Definition of locale::category\&. " .in -1c .SS "Public Member Functions" .in +1c .ti -1c .RI "\fBlocale\fP () throw ()" .br .RI "Default constructor\&. " .ti -1c .RI "\fBlocale\fP (const char *__s)" .br .RI "Named locale constructor\&. " .ti -1c .RI "\fBlocale\fP (const \fBlocale\fP &__base, const char *__s, \fBcategory\fP __cat)" .br .RI "Construct locale with facets from another locale\&. " .ti -1c .RI "\fBlocale\fP (const \fBlocale\fP &__base, const \fBlocale\fP &__add, \fBcategory\fP __cat)" .br .RI "Construct locale with facets from another locale\&. " .ti -1c .RI "\fBlocale\fP (const \fBlocale\fP &__base, const \fBstd::string\fP &__s, \fBcategory\fP __cat)" .br .RI "Construct locale with facets from another locale\&. " .ti -1c .RI "\fBlocale\fP (const \fBlocale\fP &__other) throw ()" .br .RI "Copy constructor\&. " .ti -1c .RI "template \fBlocale\fP (const \fBlocale\fP &__other, _Facet *__f)" .br .RI "Construct locale with another facet\&. " .ti -1c .RI "\fBlocale\fP (const \fBstd::string\fP &__s)" .br .RI "Named locale constructor\&. " .ti -1c .RI "\fB~locale\fP () throw ()" .br .RI "Locale destructor\&. " .ti -1c .RI "template \fBlocale\fP \fBcombine\fP (const \fBlocale\fP &__other) const" .br .RI "Construct locale with another facet\&. " .ti -1c .RI "_GLIBCXX_DEFAULT_ABI_TAG \fBstring\fP \fBname\fP () const" .br .RI "Return locale name\&. " .ti -1c .RI "bool \fBoperator!=\fP (const \fBlocale\fP &__other) const throw ()" .br .RI "Locale inequality\&. " .ti -1c .RI "template bool \fBoperator()\fP (const \fBbasic_string\fP< _Char, _Traits, _Alloc > &__s1, const \fBbasic_string\fP< _Char, _Traits, _Alloc > &__s2) const" .br .RI "Compare two strings according to collate\&. " .ti -1c .RI "template bool \fBoperator()\fP (const \fBbasic_string\fP< _CharT, _Traits, _Alloc > &__s1, const \fBbasic_string\fP< _CharT, _Traits, _Alloc > &__s2) const" .br .ti -1c .RI "const \fBlocale\fP & \fBoperator=\fP (const \fBlocale\fP &__other) throw ()" .br .RI "Assignment operator\&. " .ti -1c .RI "bool \fBoperator==\fP (const \fBlocale\fP &__other) const throw ()" .br .RI "Locale equality\&. " .in -1c .SS "Static Public Member Functions" .in +1c .ti -1c .RI "static const \fBlocale\fP & \fBclassic\fP ()" .br .RI "Return reference to the C locale\&. " .ti -1c .RI "static \fBlocale\fP \fBglobal\fP (const \fBlocale\fP &__loc)" .br .RI "Set global locale\&. " .in -1c .SS "Static Public Attributes" .PP .RI "\fB\fP" .br .in +1c .in +1c .ti -1c .RI "static const \fBcategory\fP \fBnone\fP" .br .RI "Category values\&. " .ti -1c .RI "static const \fBcategory\fP \fBctype\fP" .br .RI "Category values\&. " .ti -1c .RI "static const \fBcategory\fP \fBnumeric\fP" .br .RI "Category values\&. " .ti -1c .RI "static const \fBcategory\fP \fBcollate\fP" .br .RI "Category values\&. " .ti -1c .RI "static const \fBcategory\fP \fBtime\fP" .br .RI "Category values\&. " .ti -1c .RI "static const \fBcategory\fP \fBmonetary\fP" .br .RI "Category values\&. " .ti -1c .RI "static const \fBcategory\fP \fBmessages\fP" .br .RI "Category values\&. " .ti -1c .RI "static const \fBcategory\fP \fBall\fP" .br .RI "Category values\&. " .in -1c .in -1c .SS "Friends" .in +1c .ti -1c .RI "template struct \fB__use_cache\fP" .br .ti -1c .RI "class \fB_Impl\fP" .br .ti -1c .RI "class \fBfacet\fP" .br .ti -1c .RI "template bool \fBhas_facet\fP (const \fBlocale\fP &) throw ()" .br .RI "Test for the presence of a facet\&. " .ti -1c .RI "template const _Facet & \fBuse_facet\fP (const \fBlocale\fP &)" .br .RI "Return a facet\&. " .in -1c .SH "Detailed Description" .PP Container class for localization functionality\&. The locale class is first a class wrapper for C library locales\&. It is also an extensible container for user-defined localization\&. A locale is a collection of facets that implement various localization features such as money, time, and number printing\&. .PP Constructing C++ locales does not change the C library locale\&. .PP This library supports efficient construction and copying of locales through a reference counting implementation of the locale class\&. .PP Definition at line 62 of file locale_classes\&.h\&. .SH "Member Typedef Documentation" .PP .SS "typedef int \fBstd::locale::category\fP" .PP Definition of locale::category\&. .PP Definition at line 67 of file locale_classes\&.h\&. .SH "Constructor & Destructor Documentation" .PP .SS "std::locale::locale ()" .PP Default constructor\&. Constructs a copy of the global locale\&. If no locale has been explicitly set, this is the C locale\&. .SS "std::locale::locale (const \fBlocale\fP & __other)" .PP Copy constructor\&. Constructs a copy of \fIother\fP\&. .PP \fBParameters\fP .RS 4 \fI__other\fP The locale to copy\&. .RE .PP .SS "std::locale::locale (const char * __s)\fC [explicit]\fP" .PP Named locale constructor\&. Constructs a copy of the named C library locale\&. .PP \fBParameters\fP .RS 4 \fI__s\fP Name of the locale to construct\&. .RE .PP \fBExceptions\fP .RS 4 \fIstd::runtime_error\fP if __s is null or an undefined locale\&. .RE .PP .SS "std::locale::locale (const \fBlocale\fP & __base, const char * __s, \fBcategory\fP __cat)" .PP Construct locale with facets from another locale\&. Constructs a copy of the locale \fIbase\fP\&. The facets specified by \fIcat\fP are replaced with those from the locale named by \fIs\fP\&. If base is named, this locale instance will also be named\&. .PP \fBParameters\fP .RS 4 \fI__base\fP The locale to copy\&. .br \fI__s\fP Name of the locale to use facets from\&. .br \fI__cat\fP Set of categories defining the facets to use from __s\&. .RE .PP \fBExceptions\fP .RS 4 \fIstd::runtime_error\fP if __s is null or an undefined locale\&. .RE .PP .SS "std::locale::locale (const \fBstd::string\fP & __s)\fC [inline]\fP, \fC [explicit]\fP" .PP Named locale constructor\&. Constructs a copy of the named C library locale\&. .PP \fBParameters\fP .RS 4 \fI__s\fP Name of the locale to construct\&. .RE .PP \fBExceptions\fP .RS 4 \fIstd::runtime_error\fP if __s is an undefined locale\&. .RE .PP .PP Definition at line 163 of file locale_classes\&.h\&. .SS "std::locale::locale (const \fBlocale\fP & __base, const \fBstd::string\fP & __s, \fBcategory\fP __cat)\fC [inline]\fP" .PP Construct locale with facets from another locale\&. Constructs a copy of the locale \fIbase\fP\&. The facets specified by \fIcat\fP are replaced with those from the locale named by \fIs\fP\&. If base is named, this locale instance will also be named\&. .PP \fBParameters\fP .RS 4 \fI__base\fP The locale to copy\&. .br \fI__s\fP Name of the locale to use facets from\&. .br \fI__cat\fP Set of categories defining the facets to use from __s\&. .RE .PP \fBExceptions\fP .RS 4 \fIstd::runtime_error\fP if __s is an undefined locale\&. .RE .PP .PP Definition at line 177 of file locale_classes\&.h\&. .SS "std::locale::locale (const \fBlocale\fP & __base, const \fBlocale\fP & __add, \fBcategory\fP __cat)" .PP Construct locale with facets from another locale\&. Constructs a copy of the locale \fIbase\fP\&. The facets specified by \fIcat\fP are replaced with those from the locale \fIadd\fP\&. If \fIbase\fP and \fIadd\fP are named, this locale instance will also be named\&. .PP \fBParameters\fP .RS 4 \fI__base\fP The locale to copy\&. .br \fI__add\fP The locale to use facets from\&. .br \fI__cat\fP Set of categories defining the facets to use from add\&. .RE .PP .SS "template std::locale::locale (const \fBlocale\fP & __other, _Facet * __f)" .PP Construct locale with another facet\&. Constructs a copy of the locale \fI__other\fP\&. The facet \fI__f\fP is added to \fI__other\fP, replacing an existing facet of type Facet if there is one\&. If \fI__f\fP is null, this locale is a copy of \fI__other\fP\&. .PP \fBParameters\fP .RS 4 \fI__other\fP The locale to copy\&. .br \fI__f\fP The facet to add in\&. .RE .PP .PP Definition at line 44 of file locale_classes\&.tcc\&. .SS "std::locale::~locale ()" .PP Locale destructor\&. .SH "Member Function Documentation" .PP .SS "static const \fBlocale\fP& std::locale::classic ()\fC [static]\fP" .PP Return reference to the C locale\&. .SS "template \fBlocale\fP std::locale::combine (const \fBlocale\fP & __other) const" .PP Construct locale with another facet\&. Constructs and returns a new copy of this locale\&. Adds or replaces an existing facet of type Facet from the locale \fIother\fP into the new locale\&. .PP \fBTemplate Parameters\fP .RS 4 \fI_Facet\fP The facet type to copy from other .RE .PP \fBParameters\fP .RS 4 \fI__other\fP The locale to copy from\&. .RE .PP \fBReturns\fP .RS 4 Newly constructed locale\&. .RE .PP \fBExceptions\fP .RS 4 \fIstd::runtime_error\fP if __other has no facet of type _Facet\&. .RE .PP .PP Definition at line 62 of file locale_classes\&.tcc\&. .SS "static \fBlocale\fP std::locale::global (const \fBlocale\fP & __loc)\fC [static]\fP" .PP Set global locale\&. This function sets the global locale to the argument and returns a copy of the previous global locale\&. If the argument has a name, it will also call std::setlocale(LC_ALL, loc\&.name())\&. .PP \fBParameters\fP .RS 4 \fI__loc\fP The new locale to make global\&. .RE .PP \fBReturns\fP .RS 4 Copy of the old global locale\&. .RE .PP .SS "_GLIBCXX_DEFAULT_ABI_TAG \fBstring\fP std::locale::name () const" .PP Return locale name\&. .PP \fBReturns\fP .RS 4 Locale name or '*' if unnamed\&. .RE .PP .SS "bool std::locale::operator!= (const \fBlocale\fP & __other) const\fC [inline]\fP" .PP Locale inequality\&. .PP \fBParameters\fP .RS 4 \fI__other\fP The locale to compare against\&. .RE .PP \fBReturns\fP .RS 4 ! (*this == __other) .RE .PP .PP Definition at line 264 of file locale_classes\&.h\&. .SS "template bool std::locale::operator() (const \fBbasic_string\fP< _Char, _Traits, _Alloc > & __s1, const \fBbasic_string\fP< _Char, _Traits, _Alloc > & __s2) const" .PP Compare two strings according to collate\&. Template operator to compare two strings using the compare function of the collate facet in this locale\&. One use is to provide the locale to the sort function\&. For example, a vector v of strings could be sorted according to locale loc by doing: .PP .nf std::sort(v\&.begin(), v\&.end(), loc); .fi .PP .PP \fBParameters\fP .RS 4 \fI__s1\fP First string to compare\&. .br \fI__s2\fP Second string to compare\&. .RE .PP \fBReturns\fP .RS 4 True if collate<_Char> facet compares __s1 < __s2, else false\&. .RE .PP .SS "const \fBlocale\fP& std::locale::operator= (const \fBlocale\fP & __other)" .PP Assignment operator\&. Set this locale to be a copy of \fIother\fP\&. .PP \fBParameters\fP .RS 4 \fI__other\fP The locale to copy\&. .RE .PP \fBReturns\fP .RS 4 A reference to this locale\&. .RE .PP .SS "bool std::locale::operator== (const \fBlocale\fP & __other) const" .PP Locale equality\&. .PP \fBParameters\fP .RS 4 \fI__other\fP The locale to compare against\&. .RE .PP \fBReturns\fP .RS 4 True if other and this refer to the same locale instance, are copies, or have the same name\&. False otherwise\&. .RE .PP .SH "Friends And Related Function Documentation" .PP .SS "template bool has_facet (const \fBlocale\fP &)\fC [friend]\fP" .PP Test for the presence of a facet\&. has_facet tests the locale argument for the presence of the facet type provided as the template parameter\&. Facets derived from the facet parameter will also return true\&. .PP \fBTemplate Parameters\fP .RS 4 \fI_Facet\fP The facet type to test the presence of\&. .RE .PP \fBParameters\fP .RS 4 \fI__loc\fP The locale to test\&. .RE .PP \fBReturns\fP .RS 4 true if \fC__loc\fP contains a facet of type _Facet, else false\&. .RE .PP .PP Definition at line 104 of file locale_classes\&.tcc\&. .SS "template const _Facet& use_facet (const \fBlocale\fP &)\fC [friend]\fP" .PP Return a facet\&. use_facet looks for and returns a reference to a facet of type Facet where Facet is the template parameter\&. If has_facet(locale) is true, there is a suitable facet to return\&. It throws std::bad_cast if the locale doesn't contain a facet of type Facet\&. .PP \fBTemplate Parameters\fP .RS 4 \fI_Facet\fP The facet type to access\&. .RE .PP \fBParameters\fP .RS 4 \fI__loc\fP The locale to use\&. .RE .PP \fBReturns\fP .RS 4 Reference to facet of type Facet\&. .RE .PP \fBExceptions\fP .RS 4 \fIstd::bad_cast\fP if \fC__loc\fP doesn't contain a facet of type _Facet\&. .RE .PP .PP Definition at line 132 of file locale_classes\&.tcc\&. .SH "Member Data Documentation" .PP .SS "const \fBcategory\fP std::locale::all\fC [static]\fP" .PP Category values\&. The standard category values are none, ctype, numeric, collate, time, monetary, and messages\&. They form a bitmask that supports union and intersection\&. The category all is the union of these values\&. .PP NB: Order must match _S_facet_categories definition in locale\&.cc .PP Definition at line 105 of file locale_classes\&.h\&. .SS "const \fBcategory\fP std::locale::collate\fC [static]\fP" .PP Category values\&. The standard category values are none, ctype, numeric, collate, time, monetary, and messages\&. They form a bitmask that supports union and intersection\&. The category all is the union of these values\&. .PP NB: Order must match _S_facet_categories definition in locale\&.cc .PP Definition at line 101 of file locale_classes\&.h\&. .SS "const \fBcategory\fP std::locale::ctype\fC [static]\fP" .PP Category values\&. The standard category values are none, ctype, numeric, collate, time, monetary, and messages\&. They form a bitmask that supports union and intersection\&. The category all is the union of these values\&. .PP NB: Order must match _S_facet_categories definition in locale\&.cc .PP Definition at line 99 of file locale_classes\&.h\&. .SS "const \fBcategory\fP std::locale::messages\fC [static]\fP" .PP Category values\&. The standard category values are none, ctype, numeric, collate, time, monetary, and messages\&. They form a bitmask that supports union and intersection\&. The category all is the union of these values\&. .PP NB: Order must match _S_facet_categories definition in locale\&.cc .PP Definition at line 104 of file locale_classes\&.h\&. .SS "const \fBcategory\fP std::locale::monetary\fC [static]\fP" .PP Category values\&. The standard category values are none, ctype, numeric, collate, time, monetary, and messages\&. They form a bitmask that supports union and intersection\&. The category all is the union of these values\&. .PP NB: Order must match _S_facet_categories definition in locale\&.cc .PP Definition at line 103 of file locale_classes\&.h\&. .SS "const \fBcategory\fP std::locale::none\fC [static]\fP" .PP Category values\&. The standard category values are none, ctype, numeric, collate, time, monetary, and messages\&. They form a bitmask that supports union and intersection\&. The category all is the union of these values\&. .PP NB: Order must match _S_facet_categories definition in locale\&.cc .PP Definition at line 98 of file locale_classes\&.h\&. .SS "const \fBcategory\fP std::locale::numeric\fC [static]\fP" .PP Category values\&. The standard category values are none, ctype, numeric, collate, time, monetary, and messages\&. They form a bitmask that supports union and intersection\&. The category all is the union of these values\&. .PP NB: Order must match _S_facet_categories definition in locale\&.cc .PP Definition at line 100 of file locale_classes\&.h\&. .SS "const \fBcategory\fP std::locale::time\fC [static]\fP" .PP Category values\&. The standard category values are none, ctype, numeric, collate, time, monetary, and messages\&. They form a bitmask that supports union and intersection\&. The category all is the union of these values\&. .PP NB: Order must match _S_facet_categories definition in locale\&.cc .PP Definition at line 102 of file locale_classes\&.h\&. .SH "Author" .PP Generated automatically by Doxygen for libstdc++ from the source code\&.