Skip to content

Commit 7ae4be4

Browse files
committed
functional: C++26 P2714R1 (#1200)
- bind_{back,front}: 事前条件,適格要件を仕様通りに書換 - not_fn: C++20以降の戻り値定義を追記(C++17定義も維持)
1 parent 1dd1b04 commit 7ae4be4

File tree

3 files changed

+71
-29
lines changed

3 files changed

+71
-29
lines changed

reference/functional/bind_back.md

+25-8
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,10 @@
77
```cpp
88
namespace std {
99
template <class F, class... Args>
10-
constexpr unspecified bind_back(F&&, Args&&...);
10+
constexpr unspecified bind_back(F&& f, Args&&... args); // (1) C++23
11+
12+
template <auto f, class... Args>
13+
constexpr unspecified bind_back(Args&&... args); // (2) C++26
1114
}
1215
```
1316
* unspecified[italic]
@@ -17,16 +20,24 @@ namespace std {
1720
1821
先頭から適用する場合は[`bind_front`](bind_front.md)を用いる。
1922
20-
## テンプレートパラメータ制約
21-
[`decay_t`](/reference/type_traits/decay.md)`<F>`を適用した型を`FD`、
22-
[`std::decay_t`](/reference/type_traits/decay.md)`<Args>...`を適用した型パラメータパックを`BoundArgs`であるとして、
2323
24-
- `FD`が[`std::move_constructible`](/reference/concepts/move_constructible.md)要件を満たすこと
25-
- `BoundArgs`のそれぞれの型`Ti`が[オブジェクト型](/reference/type_traits/is_object.md)である場合、[`std::move_constructible`](/reference/concepts/move_constructible.md)要件を満たすこと
24+
## 事前条件
25+
[`decay_t`](/reference/type_traits/decay.md)`<F>`を適用した型を`FD`、[`decay_t`](/reference/type_traits/decay.md)`<Args>...`を適用した型パラメータパックを`BoundArgs`として
26+
27+
- (1) :
28+
- `FD`がCpp17MoveConstructible要件を満たすこと
29+
- `BoundArgs`のそれぞれの型`Ti`が[オブジェクト型](/reference/type_traits/is_object.md)である場合、Cpp17MoveConstructible要件を満たすこと
30+
- (2) :
31+
- `BoundArgs`のそれぞれの型`Ti`がCpp17MoveConstructible要件を満たすこと
2632
2733
2834
## 適格要件
29-
- [`conjunction_v`](/reference/type_traits/conjunction.md)`<`[`is_constructible`](/reference/type_traits/is_constructible.md)`<FD, F>,` [`is_move_constructible`](/reference/type_traits/is_move_constructible.md)`<FD>,` [`is_constructible`](/reference/type_traits/is_constructible.md)`<BoundArgs, Args>...,` [`is_move_constructible`](/reference/type_traits/is_move_constructible.md)`<BoundArgs>...>`が`true`であること
35+
- (1) :
36+
- [`is_constructible_v`](/reference/type_traits/is_constructible.md)`<FD, F> &&` [`is_move_constructible_v`](/reference/type_traits/is_move_constructible.md)`<FD> &&` `(`[`is_constructible_v`](/reference/type_traits/is_constructible.md)`<BoundArgs, Args> && ...) &&` `(`[`is_move_constructible_v`](/reference/type_traits/is_move_constructible.md)`<BoundArgs> && ...)`が`true`であること
37+
- (2) : `F`を`f`の型として
38+
- `(`[`is_constructible_v`](/reference/type_traits/is_constructible.md)`<BoundArgs, Args> && ...)`が`true`、かつ
39+
- `(`[`is_move_constructible_v`](/reference/type_traits/is_move_constructible.md)`<BoundArgs> && ...)`が`true`、かつ
40+
- もし[`is_poinetr_v`](/reference/type_traits/is_pointer.md)`<F> ||` [`is_member_poinetr_v`](/reference/type_traits/is_member_pointer.md)`<F>`が`true`ならば、`f != nullptr`であること
3041
3142
3243
## 戻り値
@@ -35,8 +46,11 @@ namespace std {
3546
3647
返される関数オブジェクトは渡された引数(`f, args...`)を参照として保持せず、適切にコピー/ムーブして保持する。
3748
49+
3850
## 例外
39-
- 関数オブジェクト`f`のムーブによって任意の例外が送出される可能性がある
51+
- (1) : 関数オブジェクト`f`のムーブによって任意の例外が送出される可能性がある
52+
- (2) : `bound_args`の初期化による任意の例外が送出される可能性がある
53+
4054
4155
## この機能が必要になった背景・経緯
4256
@@ -132,6 +146,9 @@ int main() {
132146
- [ICC](/implementation.md#icc): ??
133147
- [Visual C++](/implementation.md#visual_cpp): ??
134148

149+
135150
## 参照
136151
- [P2387R3 Pipe support for user-defined range adaptors](https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2021/p2387r3.html#nanorange)
137152
- [rangesのパイプにアダプトするには](https://onihusube.hatenablog.com/entry/2022/04/24/010041)
153+
- [P2714R1 Bind front and back to NTTP callables](https://open-std.org/jtc1/sc22/wg21/docs/papers/2023/p2714r1.html)
154+
- C++26でオーバーロード(2)を追加

reference/functional/bind_front.md

+22-8
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,10 @@
77
```cpp
88
namespace std {
99
template <class F, class... Args>
10-
constexpr unspecified bind_front(F&&, Args&&...);
10+
constexpr unspecified bind_front(F&& f, Args&&... args); // (1) C++20
11+
12+
template <auto f, class... Args>
13+
constexpr unspecified bind_front(Args&&... args); // (2) C++26
1114
}
1215
```
1316
* unspecified[italic]
@@ -49,16 +52,23 @@ auto f3 = bind_front(&Strategy::process, Strategy{});
4952
ただし、この関数はメンバ関数とレシーバーを受け取る専用にはなっておらず、「引数を先頭から順に束縛する」という汎用的な機能になっているため、「メンバ関数ポインタのみを束縛」「関数と引数の一部を束縛」といった利用もできる。
5053

5154

52-
## テンプレートパラメータ制約
53-
[`decay_t`](/reference/type_traits/decay.md)`<F>`を適用した型を`FD`、
54-
[`std::decay_t`](/reference/type_traits/decay.md)`<Args>...`を適用した型パラメータパックを`BoundArgs`であるとして、
55+
## 事前条件
56+
[`decay_t`](/reference/type_traits/decay.md)`<F>`を適用した型を`FD`、[`decay_t`](/reference/type_traits/decay.md)`<Args>...`を適用した型パラメータパックを`BoundArgs`として
5557

56-
- `FD`が[`std::move_constructible`](/reference/concepts/move_constructible.md)要件を満たすこと
57-
- `BoundArgs`のそれぞれの型`Ti`が[オブジェクト型](/reference/type_traits/is_object.md)である場合、[`std::move_constructible`](/reference/concepts/move_constructible.md)要件を満たすこと
58+
- (1) :
59+
- `FD`がCpp17MoveConstructible要件を満たすこと
60+
- `BoundArgs`のそれぞれの型`Ti`が[オブジェクト型](/reference/type_traits/is_object.md)である場合、Cpp17MoveConstructible要件を満たすこと
61+
- (2) :
62+
- `BoundArgs`のそれぞれの型`Ti`がCpp17MoveConstructible要件を満たすこと
5863

5964

6065
## 適格要件
61-
- [`conjunction_v`](/reference/type_traits/conjunction.md)`<`[`is_constructible`](/reference/type_traits/is_constructible.md)`<FD, F>,` [`is_move_constructible`](/reference/type_traits/is_move_constructible.md)`<FD>,` [`is_constructible`](/reference/type_traits/is_constructible.md)`<BoundArgs, Args>...,` [`is_move_constructible`](/reference/type_traits/is_move_constructible.md)`<BoundArgs>...>`が`true`であること
66+
- (1) :
67+
- [`is_constructible_v`](/reference/type_traits/is_constructible.md)`<FD, F> &&` [`is_move_constructible_v`](/reference/type_traits/is_move_constructible.md)`<FD> &&` `(`[`is_constructible_v`](/reference/type_traits/is_constructible.md)`<BoundArgs, Args> && ...) &&` `(`[`is_move_constructible_v`](/reference/type_traits/is_move_constructible.md)`<BoundArgs> && ...)`が`true`であること
68+
- (2) : `F`を`f`の型として
69+
- `(`[`is_constructible_v`](/reference/type_traits/is_constructible.md)`<BoundArgs, Args> && ...)`が`true`、かつ
70+
- `(`[`is_move_constructible_v`](/reference/type_traits/is_move_constructible.md)`<BoundArgs> && ...)`が`true`、かつ
71+
- もし[`is_poinetr_v`](/reference/type_traits/is_pointer.md)`<F> ||` [`is_member_poinetr_v`](/reference/type_traits/is_member_pointer.md)`<F>`が`true`ならば、`f != nullptr`であること
6272

6373

6474
## 戻り値
@@ -67,8 +77,10 @@ auto f3 = bind_front(&Strategy::process, Strategy{});
6777

6878
返される関数オブジェクトは渡された引数(`f, args...`)を参照として保持せず、適切にコピー/ムーブして保持する。
6979

80+
7081
## 例外
71-
- 関数オブジェクト`f`のムーブによって任意の例外が送出される可能性がある
82+
- (1) : 関数オブジェクト`f`のムーブによって任意の例外が送出される可能性がある
83+
- (2) : `bound_args`の初期化による任意の例外が送出される可能性がある
7284

7385

7486
## 例
@@ -132,3 +144,5 @@ int main() {
132144
## 参照
133145
- [P0356R5 Simplified partial function application](http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2018/p0356r5.html)
134146
- [P1651R0 `bind_front` should not unwrap `reference_wrapper`](http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2019/p1651r0.html)
147+
- [P2714R1 Bind front and back to NTTP callables](https://open-std.org/jtc1/sc22/wg21/docs/papers/2023/p2714r1.html)
148+
- C++26でオーバーロード(2)を追加

reference/functional/not_fn.md

+24-13
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,12 @@
77
```cpp
88
namespace std {
99
template <class F>
10-
unspecified not_fn(F&& f); //C++17
11-
10+
unspecified not_fn(F&& f); // (1) C++17
1211
template <class F>
13-
constexpr unspecified not_fn(F&& f); //C++20
12+
constexpr unspecified not_fn(F&& f); // (1) C++20
13+
14+
template <auto f>
15+
constexpr unspecified not_fn(); // (2) C++26
1416
}
1517
```
1618
* unspecified[italic]
@@ -19,20 +21,18 @@ namespace std {
1921
任意個数の引数をとって`bool`型を返す関数オブジェクトを受け取り、戻り値を論理反転する関数オブジェクトに変換する。
2022
2123
22-
## テンプレートパラメータ制約
23-
[`decay_t`](/reference/type_traits/decay.md)`<F>`を適用した型を`FD`として、
24-
25-
- `FD`が[`std::move_constructible`](/reference/concepts/move_constructible.md)要件を満たすこと
24+
## 事前条件
25+
- (1) : [`decay_t`](/reference/type_traits/decay.md)`<F>`を適用した型を`FD`として、`FD`がCpp17MoveConstructible要件を満たすこと
2626
2727
2828
## 適格要件
29-
[`decay_t`](/reference/type_traits/decay.md)`<F>`を適用した型を`FD`として、
30-
31-
- [`is_constructible_v`](/reference/type_traits/is_constructible.md)`<FD, F>`が`true`であること
32-
- [`is_move_constructible_v`](/reference/type_traits/is_move_constructible.md)`<FD>`が`true`であること
29+
- (1) : [`decay_t`](/reference/type_traits/decay.md)`<F>`を適用した型を`FD`として、
30+
- [`is_constructible_v`](/reference/type_traits/is_constructible.md)`<FD, F>`が`true`、かつ
31+
- [`is_move_constructible_v`](/reference/type_traits/is_move_constructible.md)`<FD>`が`true`であること
32+
- (2) : `F`を`f`の型として、もし[`is_poinetr_v`](/reference/type_traits/is_pointer.md)`<F> ||` [`is_member_poinetr_v`](/reference/type_traits/is_member_pointer.md)`<F>`が`true`ならば、`f != nullptr`であること
3333
3434
35-
## 効果
35+
## 効果(C++17)
3636
説明用の関数オブジェクト`call_wrapper`があるものとして、`call_wrapper(`[`std::forward`](/reference/utility/forward.md)`<F>(f))`を返す。
3737
3838
説明用の関数オブジェクト`call_wrapper`は、以下のようなクラスである:
@@ -75,8 +75,17 @@ private:
7575
- 右辺値参照版 : `return !`[`INVOKE`](/reference/concepts/Invoke.md)`(`[`std::move`](/reference/utility/move.md)`(fd),` [`std::forward`](/reference/utility/forward.md)`<Args>(args)...)`
7676

7777

78+
## 戻り値(C++20)
79+
結果オブジェクト`g`に対する関数呼び出し式の引数パック`call_args`としたとき
80+
81+
- (1) : `fd`[`std::forward`](/reference/utility/forward.md)`<F>(f))`で直接非リスト初期化した`FD`型のオブジェクトに対して
82+
- 関数呼び出し式の結果が`!`[`invoke`](invoke.md)`(fd, call_args...)`に等しい、完全転送呼び出しラッパー(perfect forwarding call wrapper)オブジェクトを返す。
83+
- (2) :
84+
- 関数呼び出し式の結果が`!`[`invoke`](invoke.md)`(f, call_args...)`に等しい、状態を持たない完全転送呼び出しラッパー(perfect forwarding call wrapper)オブジェクトを返す。
85+
86+
7887
## 例外
79-
- 関数オブジェクト`f`のムーブによって任意の例外が送出される可能性がある
88+
- (1) : 関数オブジェクト`f`のムーブによって任意の例外が送出される可能性がある
8089

8190

8291
##
@@ -131,3 +140,5 @@ true
131140
- [LWG Issue 2767. `not_fn` `call_wrapper` can form invalid types](https://wg21.cmeerw.net/lwg/issue2767)
132141
- [P0356R5 Simplified partial function application](http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2018/p0356r5.html)
133142
- [P1065R2 constexpr INVOKE](http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2019/p1065r2.html)
143+
- [P2714R1 Bind front and back to NTTP callables](https://open-std.org/jtc1/sc22/wg21/docs/papers/2023/p2714r1.html)
144+
- C++26でオーバーロード(2)を追加

0 commit comments

Comments
 (0)