Difference between revisions of "cpp/locale/locale/global"
From cppreference.com
m (Text replace - "{{cpp|" to "{{c|") |
D41D8CD98F (Talk | contribs) (- {{dcl header|locale}}) |
||
(9 intermediate revisions by 3 users not shown) | |||
Line 1: | Line 1: | ||
− | {{cpp/locale/locale/title | global}} | + | {{cpp/locale/locale/title|global}} |
− | {{cpp/locale/locale/ | + | {{cpp/locale/locale/navbar}} |
− | {{ddcl | + | {{ddcl| |
static locale global( const locale& loc ); | static locale global( const locale& loc ); | ||
}} | }} | ||
− | Replaces the global C++ locale with {{ | + | Replaces the global C++ locale with {{c|loc}}, which means all future calls to the {{lc|std::locale}} default constructor will now return a copy of {{c|loc}}. If {{c|loc}} has a name, also replaces the C locale as if by {{c|1=std::setlocale(LC_ALL, loc.name().c_str());}}. This function is the only way to modify the global C++ locale, which is otherwise equivalent to {{c|std::locale::classic()}} at program startup. |
===Parameters=== | ===Parameters=== | ||
− | {{ | + | {{par begin}} |
− | {{ | + | {{par|loc|the new global C++ locale}} |
− | {{ | + | {{par end}} |
===Return value=== | ===Return value=== | ||
Line 17: | Line 17: | ||
===Example=== | ===Example=== | ||
− | {{example | + | {{example |
− | + | |code= | |
− | + | ||
− | + | ||
}} | }} | ||
+ | |||
+ | ===Defect reports=== | ||
+ | {{dr list begin}} | ||
+ | {{dr list item|wg=lwg|dr=8|std=C++98|before=it was unspecified whether other library functions (such<br>as {{lc|std::setlocale}}) can modify the global C++ locale|after=specified (no other<br>library functions allowed)}} | ||
+ | {{dr list end}} | ||
===See also=== | ===See also=== | ||
− | {{ | + | {{dsc begin}} |
− | {{ | + | {{dsc inc|cpp/locale/locale/dsc locale}} |
− | {{ | + | {{dsc inc|cpp/locale/locale/dsc classic}} |
− | {{ | + | {{dsc inc|cpp/locale/dsc setlocale}} |
− | {{ | + | {{dsc end}} |
+ | |||
+ | {{langlinks|de|es|fr|it|ja|pt|ru|zh}} |
Latest revision as of 22:55, 18 October 2024
static locale global( const locale& loc ); |
||
Replaces the global C++ locale with loc, which means all future calls to the std::locale default constructor will now return a copy of loc. If loc has a name, also replaces the C locale as if by std::setlocale(LC_ALL, loc.name().c_str());. This function is the only way to modify the global C++ locale, which is otherwise equivalent to std::locale::classic() at program startup.
Contents |
[edit] Parameters
loc | - | the new global C++ locale |
[edit] Return value
The previous value of the global C++ locale.
[edit] Example
This section is incomplete Reason: no example |
[edit] Defect reports
The following behavior-changing defect reports were applied retroactively to previously published C++ standards.
DR | Applied to | Behavior as published | Correct behavior |
---|---|---|---|
LWG 8 | C++98 | it was unspecified whether other library functions (such as std::setlocale) can modify the global C++ locale |
specified (no other library functions allowed) |
[edit] See also
constructs a new locale (public member function) | |
[static] |
obtains a reference to the "C" locale (public static member function) |
gets and sets the current C locale (function) |