template< class Fn, class... ArgTypes >
struct is_invocable;
template< class R, class Fn, class... ArgTypes >
struct is_invocable_r;
template< class Fn, class... ArgTypes >
struct is_nothrow_invocable;
template< class R, class Fn, class... ArgTypes >
struct is_nothrow_invocable_r;
Determines whether
INVOKE(std::declval<Fn>(), std::declval<ArgTypes>()...)is well formed when treated as an unevaluated operand, and is known not to throw any exceptions.
4)Determines whether
INVOKE<R>(std::declval<Fn>(), std::declval<ArgTypes>()...)is well formed when treated as an unevaluated operand, and is known not to throw any exceptions.
If Fn, R
or any type in the parameter pack ArgTypes
is not a complete type, (possibly cv-qualified) void, or an array of unknown bound, the behavior is undefined.
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 behavior is undefined.
If the program adds specializations for any of the templates described on this page, the behavior is undefined.
[edit] Helper variable templates template< class Fn, class... ArgTypes >inline constexpr bool is_invocable_v =
inline constexpr bool is_invocable_r_v =
inline constexpr bool is_nothrow_invocable_v =
inline constexpr bool is_nothrow_invocable_r_v =
#include <type_traits> auto func2(char) -> int (*)() { return nullptr; } int main() { static_assert(std::is_invocable_v<int()>); static_assert(not std::is_invocable_v<int(), int>); static_assert(std::is_invocable_r_v<int, int()>); static_assert(not std::is_invocable_r_v<int*, int()>); static_assert(std::is_invocable_r_v<void, void(int), int>); static_assert(not std::is_invocable_r_v<void, void(int), void>); static_assert(std::is_invocable_r_v<int(*)(), decltype(func2), char>); static_assert(not std::is_invocable_r_v<int(*)(), decltype(func2), void>); }[edit] See also invokes any Callable object with given arguments and possibility to specify return type(since C++23)
(C++11)(removed in C++20)(C++17)
deduces the result type of invoking a callable object with a set of argumentsRetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4