Skip to content

Commit e6a1afa

Browse files
committed
stacktrace : formatterの特殊化を追加
1 parent 0b3b945 commit e6a1afa

File tree

3 files changed

+85
-0
lines changed

3 files changed

+85
-0
lines changed

reference/stacktrace/basic_stacktrace.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,13 @@ namespace std {
155155
| `template <class Allocator>`<br/> `struct hash<basic_stacktrace<Allocator>>;` | `hash`クラスの`basic_stacktrace`に対する特殊化 | C++23 |
156156
157157
158+
### 文字列フォーマットサポート
159+
160+
| 名前 | 説明 | 対応バージョン |
161+
|------|------|----------------|
162+
| `template <class Allocator>`<br/> `struct formatter<basic_stacktrace<Allocator>>;` | [`formatter`](/reference/format/formatter.md)の特殊化 | C++23 |
163+
164+
158165
## 例
159166
### 基本的な使い方
160167
```cpp example
@@ -234,3 +241,6 @@ Expression 'i >= 0' is false in f(int) at /app/example.cpp:15
234241
- 13まで : `-lstdc++_libbacktrace`
235242
- 14以降 : `-lstdc++exp`
236243
244+
245+
## 参照
246+
- [P2693R1 Formatting `thread::id` and `stacktrace`](https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2023/p2693r1.pdf)

reference/stacktrace/stacktrace_entry.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,13 @@ namespace std {
8686
| `template <>`<br/> `struct hash<stacktrace_entry>;` | `hash`クラスの`stacktrace_entry`に対する特殊化 | C++23 |
8787
8888
89+
## 文字列フォーマットサポート
90+
91+
| 名前 | 説明 | 対応バージョン |
92+
|------|------|----------------|
93+
| [`formatter`](stacktrace_entry/formatter.md) | [`std::formatter`](/reference/format/formatter.md)クラスの特殊化 | C++23 |
94+
95+
8996
## 例
9097
```cpp example
9198
#include <iostream>
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
# formatter
2+
* stacktrace[meta header]
3+
* std[meta namespace]
4+
* class[meta id-type]
5+
* cpp23[meta cpp]
6+
7+
```cpp
8+
namespace std {
9+
struct formatter<stacktrace_entry>;
10+
}
11+
```
12+
13+
## 概要
14+
`stacktrace_entry`クラスに対する[`std::formatter`](/reference/format/formatter.md)クラステンプレートの特殊化。
15+
16+
フォーマットフラグとしては、以下を使用できる:
17+
18+
```
19+
[[fill] [align] [width]]
20+
```
21+
22+
23+
##
24+
```cpp example
25+
#include <print>
26+
#include <stacktrace>
27+
28+
void g() {
29+
std::stacktrace st = std::stacktrace::current(0, 1);
30+
std::stacktrace_entry entry = st[0];
31+
32+
std::println("{}", entry);
33+
std::println("{: >30}", entry);
34+
}
35+
36+
void f() {
37+
g();
38+
}
39+
40+
int main() {
41+
f();
42+
}
43+
```
44+
* std::stacktrace[link /reference/stacktrace/basic_stacktrace.md]
45+
* current[link /reference/stacktrace/basic_stacktrace/current.md]
46+
47+
### 出力
48+
```
49+
g() at /app/example.cpp:5
50+
g() at /app/example.cpp:5
51+
```
52+
53+
## バージョン
54+
### 言語
55+
- C++23
56+
57+
### 処理系
58+
- [Clang](/implementation.md#clang): ??
59+
- [GCC](/implementation.md#gcc): 14
60+
- [Visual C++](/implementation.md#visual_cpp): ??
61+
62+
63+
## 関連項目
64+
- [`std::format()`](/reference/format/format.md) (フォーマットの詳細)
65+
66+
67+
## 参照
68+
- [P2693R1 Formatting `thread::id` and `stacktrace`](https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2023/p2693r1.pdf)

0 commit comments

Comments
 (0)