Skip to content

Commit 94f5a4f

Browse files
committed
format関連をC++26でconstexpr対応 #1576
1 parent 8198ec3 commit 94f5a4f

21 files changed

Lines changed: 279 additions & 67 deletions

lang/cpp26.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,7 @@ C++26とは、2026年中に改訂される予定の、C++バージョンの通
278278
- ポインタ出力のサポートを追加
279279
- 幅と精度を動的に指定した場合でも型の検証がコンパイル時に行われるよう仕様を見直し
280280
- コンパイル時の書式文字列だけでなく、実行時の書式文字列を渡せるよう仕様修正
281-
- `constexpr`に対応
281+
- 非ロケール版を`constexpr`に対応
282282
- [`std::to_string()`](/reference/string/to_string.md)[`std::to_wstring()`](/reference/string/to_wstring.md)の整数オーバーロードが`constexpr`に対応
283283
- [`std::basic_string`](/reference/string/basic_string.md)クラスと[`std::basic_string_view`](/reference/string_view/basic_string_view.md)クラスに、部分文字列を[`std::basic_string_view`](/reference/string_view/basic_string_view.md)として取得するメンバ関数`subview()`を追加
284284
- [`std::basic_string`](/reference/string/basic_string.md)[`std::basic_string_view`](/reference/string_view/basic_string_view.md)[`std::basic_string`](/reference/string/basic_string.md)として連結させる`operator+`を追加

reference/format/basic_format_arg.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ namespace std {
5656
5757
| 名前 | 説明 | 対応バージョン |
5858
|-----------------|-----------------------------------|----------------|
59-
| `operator bool` | `bool`への変換演算子(空の時`false`) | C++20 |
59+
| [`operator bool`](basic_format_arg/op_bool.md) | `bool`への変換演算子(空の時`false`) | C++20 |
6060
6161
## メンバ型
6262
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# operator bool
2+
* format[meta header]
3+
* class[meta id-type]
4+
* std[meta namespace]
5+
* basic_format_arg[meta class]
6+
* cpp20[meta cpp]
7+
8+
```cpp
9+
explicit operator bool() const noexcept; // (1) C++20
10+
constexpr explicit operator bool() const noexcept; // (1) C++26
11+
```
12+
13+
## 概要
14+
`bool`型への変換演算子。
15+
16+
17+
## 戻り値
18+
空でない場合に`true`を返す
19+
20+
21+
## バージョン
22+
### 言語
23+
- C++20
24+
25+
### 処理系
26+
- [Clang](/implementation.md#clang): ??
27+
- [GCC](/implementation.md#gcc): ??
28+
- [ICC](/implementation.md#icc): ??
29+
- [Visual C++](/implementation.md#visual_cpp): ??
30+
31+
## 参照
32+
- [P3391R2 `constexpr std::format`](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p3391r2.html)
33+
- C++26から`constexpr`に対応した

reference/format/basic_format_arg/op_constructor.md

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,16 @@ namespace std {
1919
const char_type*, basic_string_view<char_type>,
2020
const void*, handle> value; // exposition only
2121

22-
template<class T> explicit basic_format_arg(T& v) noexcept; // (2) exposition only
22+
template<class T>
23+
explicit
24+
basic_format_arg(T& v) noexcept; // (2) C++20 exposition only
25+
template<class T>
26+
constexpr explicit
27+
basic_format_arg(T& v) noexcept; // (2) C++26 exposition only
2328

2429
public:
25-
basic_format_arg() noexcept; // (1)
30+
basic_format_arg() noexcept; // (1) C++20
31+
constexpr basic_format_arg() noexcept; // (1) C++26
2632
};
2733
}
2834
```
@@ -83,4 +89,6 @@ namespace std {
8389
8490
## 参照
8591
86-
* [P0645R10 Text Formatting](http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2019/p0645r10.html)
92+
- [P0645R10 Text Formatting](http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2019/p0645r10.html)
93+
- [P3391R2 `constexpr std::format`](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p3391r2.html)
94+
- C++26から`constexpr`に対応した

reference/format/basic_format_args/get.md

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,10 @@
77
* cpp20[meta cpp]
88

99
```cpp
10-
basic_format_arg<Context> get(std::size_t i) const noexcept;
10+
basic_format_arg<Context>
11+
get(std::size_t i) const noexcept; // (1) C++20
12+
constexpr basic_format_arg<Context>
13+
get(std::size_t i) const noexcept; // (1) C++26
1114
```
1215
* basic_format_arg[link /reference/format/basic_format_arg.md]
1316
@@ -49,5 +52,6 @@ namespace std {
4952
- [Visual C++](/implementation.md#visual_cpp): ??
5053

5154
## 参照
52-
53-
* [P0645R10 Text Formatting](http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2019/p0645r10.html)
55+
- [P0645R10 Text Formatting](http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2019/p0645r10.html)
56+
- [P3391R2 `constexpr std::format`](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p3391r2.html)
57+
- C++26から`constexpr`に対応した

reference/format/basic_format_args/op_constructor.md

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,15 @@
77
* cpp20[meta cpp]
88

99
```cpp
10-
basic_format_args() noexcept; // (1)
10+
basic_format_args() noexcept; // (1) C++20
1111

1212
template<class... Args>
13-
basic_format_args(const format_arg_store<Context, Args...>& store) noexcept; // (2)
13+
basic_format_args(
14+
const format_arg_store<Context, Args...>& store) noexcept; // (2) C++20
15+
template<class... Args>
16+
constexpr
17+
basic_format_args(
18+
const format_arg_store<Context, Args...>& store) noexcept; // (2) C++26
1419
```
1520
* basic_format_args[link /reference/format/basic_format_args.md]
1621
* format_arg_store[italic]
@@ -63,4 +68,6 @@ namespace std {
6368

6469
## 参照
6570

66-
* [P0645R10 Text Formatting](http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2019/p0645r10.html)
71+
- [P0645R10 Text Formatting](http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2019/p0645r10.html)
72+
- [P3391R2 `constexpr std::format`](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p3391r2.html)
73+
- C++26から`constexpr`に対応した

reference/format/basic_format_context/advance_to.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
* cpp20[meta cpp]
77

88
```cpp
9-
void advance_to(iterator it);
9+
void advance_to(iterator it); // (1) C++20
10+
constexpr void advance_to(iterator it); // (1) C++26
1011
```
1112
1213
## 概要
@@ -36,3 +37,5 @@ out_ = std::move(it);
3637
## 参照
3738

3839
- [P0645R10 Text Formatting](http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2019/p0645r10.html)
40+
- [P3391R2 `constexpr std::format`](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p3391r2.html)
41+
- C++26から`constexpr`に対応した

reference/format/basic_format_context/arg.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,10 @@
66
* cpp20[meta cpp]
77

88
```cpp
9-
basic_format_arg<basic_format_context> arg(size_t id) const;
9+
basic_format_arg<basic_format_context>
10+
arg(size_t id) const; // (1) C++20
11+
constexpr basic_format_arg<basic_format_context>
12+
arg(size_t id) const; // (1) C++26
1013
```
1114
* basic_format_arg[link /reference/format/basic_format_arg.md]
1215
* basic_format_context[link /reference/format/basic_format_context.md]
@@ -28,3 +31,5 @@ basic_format_arg<basic_format_context> arg(size_t id) const;
2831
## 参照
2932
3033
- [P0645R10 Text Formatting](http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2019/p0645r10.html)
34+
- [P3391R2 `constexpr std::format`](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p3391r2.html)
35+
- C++26から`constexpr`に対応した

reference/format/basic_format_context/out.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
* cpp20[meta cpp]
77

88
```cpp
9-
iterator out();
9+
iterator out(); // (1) C++20
10+
constexpr iterator out(); // (1) C++26
1011
```
1112

1213
## 概要
@@ -36,3 +37,5 @@ return std::move(out_);
3637
## 参照
3738

3839
- [P0645R10 Text Formatting](http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2019/p0645r10.html)
40+
- [P3391R2 `constexpr std::format`](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p3391r2.html)
41+
- C++26から`constexpr`に対応した

reference/format/basic_format_string/op_constructor.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,10 @@
77

88
```cpp
99
template <class T>
10-
consteval basic_format_string(const T& s); // (1) C++23
10+
consteval
11+
basic_format_string(const T& s); // (1) C++23
1112

13+
constexpr
1214
basic_format_string(runtime-format-string<charT> s) noexcept; // (2) C++26
1315
```
1416
* runtime-format-string[link /reference/format/runtime-format-string.md]
@@ -97,3 +99,4 @@ namespace std {
9799
## 参照
98100
- [P2216R3 `std::format` improvements](https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2021/p2216r3.html)
99101
- [P2918R2 Runtime format strings II](https://open-std.org/jtc1/sc22/wg21/docs/papers/2023/p2918r2.html)
102+
- [P3391R2 `constexpr std::format`](https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p3391r2.html)

0 commit comments

Comments
 (0)