22 General utilities library [utilities] (original) (raw)
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 decltype(auto) apply(F&& f, Tuple&& t) noexcept(_see below_);
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...>) { return INVOKE(std::forward<F>(f), get<I>(std::forward<Tuple>(t))...); } }
Equivalent to:return apply-impl(std::forward<F>(f), std::forward<Tuple>(t), make_index_sequence<tuple_size_v<remove_reference_t<Tuple>>>{});
Remarks: Let I be the pack0, 1, ..., (tuple_size_v<remove_reference_t<Tuple>> - 1).
The exception specification is equivalent to:noexcept(invoke(std::forward<F>(f), get<I>(std::forward<Tuple>(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<Tuple>> is 1, thenreference_constructs_from_temporary_v<T, decltype(get<0>(declval<Tuple>()))>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<I>(declval<Tuple>()))...> constexpr T make-from-tuple-impl(Tuple&& t, index_sequence<I...>) { 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:
The type of T must be supplied as an explicit template parameter, as it cannot be deduced from the argument list.
— _end note_]