std::formatter<std::thread::id>
From cppreference.com
| ヘッダ <thread> で定義 |
||
| template< class CharT > struct formatter<std::thread::id, CharT>; |
(C++23から) | |
テンプレート特殊化されたstd::formatterは、std::thread::idクラスに対して、フォーマット関数を使用してスレッド識別子をテキスト表現に変換することを可能にします。
目次 |
[編集] フォーマット仕様
フォーマット仕様の構文は次のとおりです。
| 埋め文字と配置 (任意) 幅 (任意) | |||||||||
埋め文字と配置および幅は、標準フォーマット仕様と同じ意味を持ちます。デフォルトの配置は>です。
フォーマットされた出力は、フォーマット指定子に応じて調整されたoperator<<の出力と一致します。
[編集] 注記
| 機能テストマクロ | 値 | 規格 | 機能 |
|---|---|---|---|
__cpp_lib_formatters |
202302L |
(C++23) | std::thread::idおよびstd::stacktraceのフォーマット |
[編集] 例
このコードを実行
#include <format> #include <iostream> #include <thread> int main() { std::thread::id this_id = std::this_thread::get_id(); std::thread::id null_id; std::cout << std::format("current thread id: {}\n", this_id); std::cout << std::format("{:=^10}\n", null_id); }
実行結果の例
current thread id: 140046396632256 ====0=====
[編集] 関連項目
| (C++20) |
与えられた型のフォーマット規則を定義する (クラステンプレート) |