Skip to content

Commit f03abf8

Browse files
committed
tuple/apply: P2517R1対応(#1098)
1 parent 1f03563 commit f03abf8

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

reference/tuple/apply.md

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,10 @@
77
```cpp
88
namespace std {
99
template<class F, class Tuple>
10-
constexpr decltype(auto) apply(F&& f, Tuple&& t);
10+
constexpr decltype(auto) apply(F&& f, Tuple&& t); // C++20まで
11+
12+
template<class F, class Tuple>
13+
constexpr decltype(auto) apply(F&& f, Tuple&& t) noexcept(see below); // C++23から
1114
}
1215
```
1316
@@ -16,7 +19,7 @@ namespace std {
1619
1720
1821
## 要件
19-
適用先の関数は[`Callable`](/reference/concepts/Callable.md)要件を満たす([INVOKE](/reference/concepts/Invoke.md)操作が可能)。展開されるものは、[`std::tuple`](../tuple.md)、[`std::array`](/reference/array/array.md)または[`std::pair`](/reference/utility/pair.md)のように、[`std::get`](/reference/array/array/get.md)と[`std::tuple_size`](/reference/array/array/tuple_size.md)をサポートする必要がある
22+
適用先の関数は[`Callable`](/reference/concepts/Callable.md)要件を満たす([INVOKE](/reference/concepts/Invoke.md)操作が可能)。展開される`Tuple`型は[`std::tuple`](../tuple.md)に限定されず、[`std::array`](/reference/array/array.md)または[`std::pair`](/reference/utility/pair.md)のように、[`std::get`](/reference/array/array/get.md)と[`std::tuple_size`](/reference/array/array/tuple_size.md)をサポートする型であればよい
2023
2124
2225
## 効果
@@ -28,6 +31,7 @@ constexpr decltype(auto) apply-impl(F&& f, Tuple&& t, std::index_sequence<I...>)
2831
return std::invoke(std::forward<F>(f), std::get<I>(std::forward<Tuple>(t))...);
2932
}
3033
```
34+
* std::get[link tuple/get.md]
3135
* std::index_sequence[link /reference/utility/index_sequence.md]
3236
* std::invoke[link /reference/functional/invoke.md]
3337
* std::forward[link /reference/utility/forward.md]
@@ -38,11 +42,17 @@ constexpr decltype(auto) apply-impl(F&& f, Tuple&& t, std::index_sequence<I...>)
3842
return apply-impl(std::forward<F>(f), std::forward<Tuple>(t),
3943
std::make_index_sequence<std::tuple_size_v<std::remove_reference_t<Tuple>>>{});
4044
```
45+
* std::tuple_size_v[link tuple_size.md]
4146
* std::make_index_sequence[link /reference/utility/make_index_sequence.md]
47+
* std::forward[link /reference/utility/forward.md]
4248
* std::remove_reference_t[link /reference/type_traits/remove_reference.md]
4349

4450
## 戻り値
45-
適用した関数の戻り値である。
51+
適用した関数呼び出しの戻り値
52+
53+
54+
## 例外
55+
C++23から : `I`をパラメータパック`0, 1, ..., (`[`tuple_size_v`](tuple_size.md)`<`[`remove_reference_t`](/reference/type_traits/remove_reference.md)`<Tuple>>-1)`としたとき、例外指定の式は次と等価 : `noexcept(`[`invoke`](/reference/functional/invoke.md)`(std::forward<F>(f), get<I>(std::forward<Tuple>(t))...))`
4656

4757

4858
##
@@ -86,7 +96,7 @@ hello
8696
8797
8898
## 関連項目
89-
- [make_from_tuple](../tuple/make_from_tuple.md)
99+
- [`make_from_tuple`](make_from_tuple.md)
90100
- [`std::tuple`](../tuple.md)
91101
- [INVOKE](/reference/concepts/Invoke.md)
92102
@@ -98,3 +108,5 @@ hello
98108
- [P0220R0 Adopt Library Fundamentals TS for C++17](http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2016/p0220r0.html)
99109
- [P0220R1 Adopt Library Fundamentals V1 TS Components for C++17 (R1)](http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2016/p0220r1.html)
100110
- [C++1z タプルを展開して関数呼び出しするapply関数 - Faith and Brave - C++で遊ぼう](https://faithandbrave.hateblo.jp/entry/2016/08/18/184315)
111+
- [P2517R1 Add a conditional `noexcept` specification to `std::apply`](https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2022/p2517r1.html)
112+
- C++23から条件付きで`noexpcet`例外指定が行われる。

0 commit comments

Comments
 (0)