Files
2025-10-25 03:02:53 +03:00

54 lines
2.4 KiB
Markdown
Raw Permalink Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

[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.3Concept 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.3Concept 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.4Requirements")}}
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.3Concept 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.3Concept 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*]