Namespaces
Variants

std::meta::apply_result

From cppreference.com
< cpp | meta
 
 
 
Reflection library
 
Reflection types and queries
Type properties
Type property queries
 
Defined in header <meta>
consteval std::meta::info apply_result( std::meta::info fn,
                                        std::meta::info tuple );
(since C++26)

Deduces the return type of an expression in which the type Fn is invoked (as if by std::apply) with the given tuple-like type of arguments Tuple, where Fn denote a Callable type or type alias represented by fn and Tuple denote a type or type alias represented by tuple.

Equivalent to return std::meta::dealias(^^std::apply_result_t<Fn, Tuple>);.

If Fn cannot be called with the arguments Tuple in unevaluated context, the program is ill-formed.

If either Fn or Tuple is not a complete type, (possibly cv-qualified) void, or an array of unknown bound, the program is ill-formed.

If an instantiation of a template above depends, directly or indirectly, on an incomplete type, and that instantiation could yield a different result if that type were hypothetically completed, the program is ill-formed.

Parameters

fn - a reflection of the Callable type
tuple - a reflection of a tuple-like type whose elements to be used as arguments

Return value

A reflection of the return type of the invocation expression as described above.

Exceptions

Throws std::meta::exception if either fn or any element of tuple does not represent a type or type alias.

Example

#include <meta>
#include <tuple>

struct S
{
    double operator()(char, int&);
    float operator()(int);
};

static_assert(^^double == apply_result(^^S, ^^std::tuple<char, int&>));
static_assert(^^float == apply_result(^^S, ^^std::tuple<int>));

int main() {}

See also

(C++17)
calls a function with a tuple of arguments
(function template) [edit]
(C++17)(C++23)
invokes any Callable object with given arguments and possibility to specify return type(since C++23)
(function template) [edit]
(C++11)(removed in C++20)(C++17)
deduces the result type of invoking a callable object with a set of arguments
(class template) [edit]
(C++11)
obtains a reference to an object of the template type argument for use in an unevaluated context
(function template) [edit]
specifies that a callable type can be invoked with a given set of argument types
(concept) [edit]
checks if a type can be invoked (as if by std::invoke) with the given argument types
(class template) [edit]
checks if the reflected type can be invoked (as if by std::invoke) with the given argument types
(function template) [edit]
checks if a reflected type can be invoked (as if by std::invoke) with the given reflected tuple of arguments
(function) [edit]
deduces the result type of invoking a callable object with the given tuple of arguments
(class template) [edit]