home | help
std::ios_base::getloc(3)       C++ Standard Libary	std::ios_base::getloc(3)

NAME
     std::ios_base::getloc - std::ios_base::getloc

Synopsis
	std::locale getloc() const;

	Returns the current locale associated with the stream.

Parameters
	(none)

Return value
	The locale object associated with the stream.

Example
	The output shown was obtained using the clang compiler.

     // Run this code

      #include <codecvt>
      #include <ctime>
      #include <iomanip>
      #include <iostream>

      int main()
      {
	  std::wbuffer_convert<std::codecvt_utf8<wchar_t>>    conv(std::cout.rd-
     buf());
	  std::wostream out(&conv);

	  out.imbue(std::locale(out.getloc(),
				new			       std::time_put_by-
     name<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:
      ae"aeaeY 2023a^1'10ae05aeY 19ae47a58c<section>

	Defect reports

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

	  DR   Applied to		Behavior as published		    Cor-
     rect behavior
	LWG 47 C++98	  the return value was misspecified as the return   cor-
     rected
			  value of imbue()

See also
	imbue sets locale
	      (public member function)

http://cppreference.com 	   2024.06.10		std::ios_base::getloc(3)

home | help