Namespaces
Variants
Views
Actions

Difference between revisions of "cpp/locale/locale/global"

From cppreference.com
< cpp‎ | locale‎ | locale
m ({{c}})
(- {{dcl header|locale}})
 
Line 2: Line 2:
 
{{cpp/locale/locale/navbar}}
 
{{cpp/locale/locale/navbar}}
  
{{ddcl|header=locale|
+
{{ddcl|
 
static locale global( const locale& loc );
 
static locale global( const locale& loc );
 
}}
 
}}

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

[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) [edit]
[static]
obtains a reference to the "C" locale
(public static member function) [edit]
gets and sets the current C locale
(function) [edit]