2.4 KiB
[tuple.apply]
22 General utilities library [utilities]
22.4 Tuples [tuple]
22.4.6 Calling a function with a tuple of arguments [tuple.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>);
Effects: Given the exposition-only function template:namespace std {template<class F, tuple-like Tuple, size_t... I>constexpr decltype(auto) apply-impl(F&& f, Tuple&& t, index_sequence<I...>) {// exposition onlyreturn INVOKE(std::forward(f), get(std::forward(t))...); // see [func.require]}}
Equivalent to:return apply-impl(std::forward(f), std::forward(t), make_index_sequence<tuple_size_v<remove_reference_t>>{});
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);
Mandates: If tuple_size_v<remove_reference_t> is 1, thenreference_constructs_from_temporary_v<T, decltype(get<0>(declval()))> is false.
Effects: Given the exposition-only function template:namespace std {template<class T, tuple-like Tuple, size_t... I>requires is_constructible_v<T, decltype(get(declval()))...>constexpr T make-from-tuple-impl(Tuple&& t, index_sequence<I...>) { // exposition onlyreturn T(get(std::forward(t))...); }}
Equivalent to:return make-from-tuple-impl( std::forward(t), make_index_sequence<tuple_size_v<remove_reference_t>>{});
[Note 1:
The type of T must be supplied as an explicit template parameter, as it cannot be deduced from the argument list.
â end note]