std::ios_base::getloc(3)
std::ios_base::getloc(3) π
okay so this page is from the C++ Standard Libary manual β yes, Libary, that's the spelling in the header, don't come for me π. It's all about std::ios_base::getloc, aka the little member function that tells you which locale your stream is currently vibing with. very locale-core, no cap π
πΈ NAME πΈ
std::ios_base::getloc β std::ios_base::getloc
β¨ Synopsis β¨
std::locale getloc() const;
Returns the current locale associated with the stream. that's the whole job, bestie β¨
π Parameters π
(none)β literally no parameters. she takes nothing, she gives locale. iconic π«Ά
π Return value π
The locale object associated with the stream. that's the return value, periodt π
π¦ Example π¦
The output shown was obtained using the clang compiler. (compiler lore, iykyk π₯)
// Run this code
#include <codecvt>
#include <ctime>
#include <iomanip>
#include <iostream>
int main()
{
std::wbuffer_convert<std::codecvt_utf8<wchar_t>>
conv(std::cout.rdbuf());
std::wostream out(&conv);
out.imbue(std::locale(out.getloc(),
new
std::time_put_byname<wchar_t>("ja_JP.utf8")));
std::time_t t = std::time(nullptr);
out << std::put_time(std::localtime(&t), L"%A %c") << '\n';
}
β Possible output β
ζ¨ζζ₯ 2023εΉ΄10ζ05ζ₯ 19ζ47ε58η§
π Defect reports π
The following behavior-changing defect reports were applied retroactively to previously published C++ standards.
- DR:
LWG 47β Applied to:C++98β Behavior as published: the return value was misspecified as the return value ofimbue()β Correct behavior: corrected
π See also π
imbueβ sets locale (public member function)
shoutout to http://cppreference.com for the source, version/date 2024.06.10, page std::ios_base::getloc(3) β bye bestie, go get that locale πβ¨
π¦ where this page comes from
- nixpkgs unstable: stdman 2024.07.05
- opensuse-leap 16.0: stdman 2024.07.05-bp160.1.9 Β· MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms