std::locale::global(3)

πŸ“¦ version 2024.07.05, in nixpkgs unstable, opensuse-leap 16.0

🏷️ NAME

std::locale::global β€” yep, literally std::locale::global again, it’s giving main-character name card πŸ’…

Hii bestie πŸ’– welcome to the std::locale::global(3) page from the C++ Standard Libary manual! Buckle up, this one’s short but lowkey important.


✨ Synopsis

It lives in the header <locale>, bestie:

Defined in header <locale>
static locale global( const locale& loc );

Okay so what it does: it 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, it 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. No cap, that’s the whole vibe 😌


🧸 Parameters

  • loc β€” the new global C++ locale 🫢

🎁 Return value

The previous value of the global C++ locale. It’s giving β€œhere’s what you had before, bestie” ✨


πŸ’… Example

This section is incomplete.

Reason: no example 😭

Not me wanting an example so bad but the page literally says there isn’t one. We respect the honesty tho 🫑

🩹 Defect reports

The following behavior-changing defect reports were applied retroactively to previously published C++ standards.

  • DR: LWG 8
  • Applied to: C++98
  • Behavior as published: it was unspecified whether other library functions (such as std::setlocale) can modify the global C++ locale
  • Correct behavior: specified (no other library functions allowed)

πŸ‘€ See also

  • constructor β€” constructs a new locale (public member function)
  • classic β€” obtains a reference to the "C" locale [static] (public static member function)
  • setlocale β€” gets and sets the current C locale (function)

πŸ—‚οΈ Category

  • * Todo no example

mwah πŸ’‹ β€” source http://cppreference.com, version/date 2024.06.10, page std::locale::global(3).

πŸ“¦ where this page comes from