std::meta::is_applicable_type, std::meta::is_nothrow_applicable_type
From cppreference.com
| Defined in header <meta>
|
||
consteval bool is_applicable_type( std::meta::info fn,
std::meta::info tuple );
|
(1) | (since C++26) |
consteval bool is_nothrow_applicable_type( std::meta::info fn,
std::meta::info tuple );
|
(2) | (since C++26) |
Determines whether the type Fn represented by fn can be invoked (as if by std::invoke) with the given tuple-like type of arguments Tuple represented by tuple.
1) Equivalent to
return std::is_applicable_v<Fn, Tuple>;.2) Equivalent to
return std::is_nothrow_applicable_v<Fn, Tuple>;.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 value to check |
| tuple | - | a reflection value of a tuple of arguments |
Return value
true if the reflected type fn can be invoked with tuple of arguments; false otherwise.
Exceptions
Throws std::meta::exception if either fn or tuple does not represent a type or type alias.
Example
Run this code
#include <meta>
#include <tuple>
void func(char);
static_assert
(
std::meta::is_applicable(^^int(), ^^std::tuple<>) &&
!std::meta::is_applicable(^^int(), ^^std::tuple<int>) &&
std::meta::is_applicable(^^std::declval(func), ^^std::tuple<char>) &&
!std::meta::is_applicable(^^std::declval(func), ^^std::tuple<char, int>)
);
int main() {}
See also
(C++17) |
calls a function with a tuple of arguments (function template) |
(C++11) |
obtains a reference to an object of the template type argument for use in an unevaluated context (function template) |
(C++26) |
deduces the result type of invoking a callable object with the given reflected tuple of arguments (function) |
(C++26) |
deduces the result type of invoking a callable object with the given tuple of arguments (class template) |
(C++26)(C++26)(C++26)(C++26) |
checks if the reflected type can be invoked (as if by std::invoke) with the given argument types (function template) |
(C++20)(C++20) |
specifies that a callable type can be invoked with a given set of argument types (concept) |
(C++17)(C++23) |
invokes any Callable object with given arguments and possibility to specify return type(since C++23) (function template) |
(C++11)(removed in C++20)(C++17) |
deduces the result type of invoking a callable object with a set of arguments (class template) |
(C++17)(C++17)(C++17)(C++17) |
checks if a type can be invoked (as if by std::invoke) with the given argument types (class template) |
(C++26)(C++26) |
checks if a type can be invoked (as if by std::invoke) with the given tuple of arguments (class template) |