Skip to content

Commit 0b3b945

Browse files
committed
format : C++26対応としてポインタ値を大文字で出力するPオプションを追加 (close #1187)
1 parent 8f62ba9 commit 0b3b945

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

reference/format/format.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -155,9 +155,10 @@ string s3 = format("{} {1}", "a", "b"); // コンパイルエラー
155155

156156
#### ポインタの場合
157157

158-
| type | 意味 | 効果 |
159-
|:-----------|:-------------------|:----------------------------------------------------------------------------------------------------------------|
160-
| p | アドレスを出力する | `0x` につづいて、`to_chars(first, last, reinterpret_cast<uintptr_t>(value), 16)` の結果を出力する |
158+
| type | 意味 | 効果 | 対応バージョン |
159+
|:-----|:-------------------|:--------------------------------------------------------------------------------------------------|----------------|
160+
| p | アドレスを出力する | `0x` につづいて、`to_chars(first, last, reinterpret_cast<uintptr_t>(value), 16)` の結果を出力する | C++20 |
161+
| P | アドレスを出力する | pと基本的に同じだが、9桁を超える場合に大文字にし、先頭に`0X`をつける | C++26 |
161162

162163
デフォルトは `p`
163164

@@ -682,3 +683,5 @@ wstring format(const locale& loc, wformat_string<Args...> fmt, const Args&... ar
682683
- [P2286R8 Formatting Ranges](https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2022/p2286r8.html)
683684
- C++23から、Range・コンテナ、`pair``tuple`のフォーマット出力、および文字・文字列のデバッグ指定 (`"?"`) が追加された
684685
- [P2418R2 Add support for `std::generator`-like types to `std::format`](https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2021/p2418r2.html)
686+
- [P2510R3 Formatting pointers](https://open-std.org/jtc1/sc22/wg21/docs/papers/2022/p2510r3.pdf)
687+
- C++26から、ポインタ値を大文字で出力する`P`オプションが追加された

0 commit comments

Comments
 (0)