std::locale (3) - Linux Manuals
std::locale: std::locale
NAME
Synopsis
Defined in header <locale>
class locale;
An object of class std::locale is an immutable indexed set of immutable facets. Each stream object of the C++ input/output library is associated with an std::locale object and uses its facets for parsing and formatting of all data. In addition, a locale object is associated with each std::basic_regex object. Locale objects can also be used as predicates that perform string collation with the standard containers and algorithms and can be accessed directly to obtain or modify the facets they hold.
Each locale constructed in a C++ program holds at least the following standard facets, but a program may define additional specializations or completely new facets and add them to any existing locale object.
Supported facets
std::collate<char> std::collate<wchar_t>
std::ctype<char> std::ctype<wchar_t>
std::codecvt<char,char,mbstate_t> std::codecvt<char32_t,char,mbstate_t>
std::codecvt<char16_t,char,mbstate_t> std::codecvt<wchar_t,char,mbstate_t>
std::moneypunct<char> std::moneypunct<wchar_t>
std::moneypunct<char,true> std::moneypunct<wchar_t,true>
std::money_get<char> std::money_get<wchar_t>
std::money_put<char> std::money_put<wchar_t>
std::numpunct<char> std::numpunct<wchar_t>
std::num_get<char> std::num_get<wchar_t>
std::num_put<char> std::num_put<wchar_t>
std::time_get<char> std::time_get<wchar_t>
std::time_put<char> std::time_put<wchar_t>
std::messages<char> std::messages<wchar_t>
Internally, a locale object is implemented as-if it is a reference-counted pointer to an array (indexed by std::locale::id) of reference-counted pointers to facets: copying a locale only copies one pointer and increments several reference counts. To maintain the standard C++ library thread safety guarantees (operations on different objects are always thread-safe), both the locale reference count and each facet reference count are updated in thread-safe manner, similar to std::shared_ptr.
Member types
id (class)
facet (class)
category (typedef)
Member objects
none a zero value of type category indicating no facet category
[static]
collate a bitmask value of type category indicating the collate facet category
[static]
ctype a bitmask value of type category indicating the ctype facet category
[static]
monetary a bitmask value of type category indicating the monetary facet category
[static]
numeric a bitmask value of type category indicating the numeric facet category
[static]
time a bitmask value of type category indicating the time facet category
[static]
messages a bitmask value of type category indicating the messages facet category
[static]
all collate | ctype | monetary | numeric | time | messages
[static]
Member functions
constructor (public member function)
destructor (public member function)
operator= (public member function)
combine (public member function)
name (public member function)
operator== (public member function)
operator!=
operator() (public member function)
global changes the global locale
[static]
classic obtains a reference to the "C" locale
[static]
Example
Demonstrates the typical prologue of a locale-sensitive program (cross-platform)
// Run this code