std::ios_base:: getloc
From cppreference.net
C++
Input/output library
| I/O manipulators | ||||
| Print functions (C++23) | ||||
| C-style I/O | ||||
| Buffers | ||||
|
(C++23)
|
||||
|
(
C++98/26*
)
|
||||
|
(C++20)
|
||||
| Streams | ||||
| Abstractions | ||||
| File I/O | ||||
| String I/O | ||||
| Array I/O | ||||
|
(C++23)
|
||||
|
(C++23)
|
||||
|
(C++23)
|
||||
|
(
C++98/26*
)
|
||||
|
(
C++98/26*
)
|
||||
|
(
C++98/26*
)
|
||||
| Synchronized Output | ||||
|
(C++20)
|
||||
| Types | ||||
| Error category interface | ||||
|
(C++11)
|
||||
|
(C++11)
|
std::ios_base
| Member functions | ||||
| Formatting | ||||
| Locales | ||||
|
ios_base::getloc
|
||||
| Internal extensible array | ||||
| Miscellaneous | ||||
| Member classes | ||||
| Member types | ||||
|
std::
locale
getloc
(
)
const
;
|
||
ストリームに関連付けられた現在のロケールを返します。
目次 |
パラメータ
(なし)
戻り値
ストリームに関連付けられたロケールオブジェクト。
例
表示されている出力はclangコンパイラを使用して取得されました。
このコードを実行
#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'; }
出力例:
木曜日 2023年10月05日 19時47分58秒
不具合報告
以下の動作変更の欠陥報告書は、以前に公開されたC++規格に対して遡及的に適用されました。
| DR | 適用対象 | 公開時の動作 | 正しい動作 |
|---|---|---|---|
| LWG 47 | C++98 |
戻り値が
imbue()
の戻り値として誤って指定されていた
|
修正済み |
関連項目
|
ロケールを設定
(公開メンバ関数) |