54 lines
2.4 KiB
Markdown
54 lines
2.4 KiB
Markdown
[tuple.apply]
|
||
|
||
# 22 General utilities library [[utilities]](./#utilities)
|
||
|
||
## 22.4 Tuples [[tuple]](tuple#apply)
|
||
|
||
### 22.4.6 Calling a function with a tuple of arguments [tuple.apply]
|
||
|
||
[ð](#lib:apply)
|
||
|
||
`template<class F, [tuple-like](tuple.like#concept:tuple-like "22.4.3 Concept tuple-like [tuple.like]") Tuple>
|
||
constexpr apply_result_t<F, Tuple> apply(F&& f, Tuple&& t)
|
||
noexcept(is_nothrow_applicable_v<F, Tuple>);
|
||
`
|
||
|
||
[1](#1)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L2695)
|
||
|
||
*Effects*: Given the exposition-only function template:namespace std {template<class F, [*tuple-like*](tuple.like#concept:tuple-like "22.4.3 Concept tuple-like [tuple.like]") Tuple, size_t... I>constexpr decltype(auto) *apply-impl*(F&& f, Tuple&& t, index_sequence<I...>) {// *exposition only*return *INVOKE*(std::forward<F>(f), get<I>(std::forward<Tuple>(t))...); // see [[func.require]](func.require "22.10.4 Requirements")}}
|
||
|
||
Equivalent to:return *apply-impl*(std::forward<F>(f), std::forward<Tuple>(t),
|
||
make_index_sequence<tuple_size_v<remove_reference_t<Tuple>>>{});
|
||
|
||
[ð](#lib:make_from_tuple)
|
||
|
||
`template<class T, [tuple-like](tuple.like#concept:tuple-like "22.4.3 Concept tuple-like [tuple.like]") Tuple>
|
||
constexpr T make_from_tuple(Tuple&& t);
|
||
`
|
||
|
||
[2](#2)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L2721)
|
||
|
||
*Mandates*: If tuple_size_v<remove_reference_t<Tuple>> is 1,
|
||
thenreference_constructs_from_temporary_v<T, decltype(get<0>(declval<Tuple>()))> is false[.](#2.sentence-1)
|
||
|
||
[3](#3)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L2728)
|
||
|
||
*Effects*: Given the exposition-only function template:namespace std {template<class T, [*tuple-like*](tuple.like#concept:tuple-like "22.4.3 Concept tuple-like [tuple.like]") Tuple, size_t... I>requires is_constructible_v<T, decltype(get<I>(declval<Tuple>()))...>constexpr T *make-from-tuple-impl*(Tuple&& t, index_sequence<I...>) { // *exposition only*return T(get<I>(std::forward<Tuple>(t))...); }}
|
||
|
||
Equivalent to:return *make-from-tuple-impl*<T>( std::forward<Tuple>(t),
|
||
make_index_sequence<tuple_size_v<remove_reference_t<Tuple>>>{});
|
||
|
||
[*Note [1](#note-1)*:
|
||
|
||
The type of T must be supplied
|
||
as an explicit template parameter,
|
||
as it cannot be deduced from the argument list[.](#3.sentence-2)
|
||
|
||
â *end note*]
|