Movatterモバイル変換


[0]ホーム

URL:


cppreference.com
Namespaces
Variants
    Actions

      std::ios_base::getloc

      From cppreference.com
      <cpp‎ |io‎ |ios base
       
       
       
       
      std::locale getloc()const;

      Returns the current locale associated with the stream.

      Contents

      [edit]Parameters

      (none)

      [edit]Return value

      The locale object associated with the stream.

      [edit]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.rdbuf());std::wostream out(&conv);     out.imbue(std::locale(out.getloc(),                          newstd::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秒

      [edit]Defect reports

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

      DRApplied toBehavior as publishedCorrect behavior
      LWG 47C++98the return value was misspecified as the return value ofimbue()corrected

      [edit]See also

      sets locale
      (public member function)[edit]
      Retrieved from "https://en.cppreference.com/mwiki/index.php?title=cpp/io/ios_base/getloc&oldid=160197"

      [8]ページ先頭

      ©2009-2025 Movatter.jp