On this page
std::is_invocable, std::is_invocable_r, std::is_nothrow_invocable, std::is_nothrow_invocable_r
Defined in header <type_traits> |
||
---|---|---|
|
(1) | (since C++17) |
|
(2) | (since C++17) |
|
(3) | (since C++17) |
|
(4) | (since C++17) |
INVOKE(std::declval<Fn>(), std::declval<ArgTypes>()...)
is well formed when treated as an unevaluated operand.
INVOKE<R>(std::declval<Fn>(), std::declval<ArgTypes>()...)
is well formed when treated as an unevaluated operand.
INVOKE(std::declval<Fn>(), std::declval<ArgTypes>()...)
is well formed when treated as an unevaluated operand, and is known not to throw any exceptions.
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.
Fn, R
and all types in the parameter pack ArgTypes
shall each be a complete type, (possibly cv-qualified) void, or an array of unknown bound. Otherwise, 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.
The behavior of a program that adds specializations for any of the templates described on this page is undefined.
Helper variable templates
Defined in header <type_traits> |
||
---|---|---|
|
(1) | (since C++17) |
|
(2) | (since C++17) |
|
(3) | (since C++17) |
|
(4) | (since C++17) |
Inherited from std::integral_constant
Member constants
value
[static]
|
true if (for overload (1)) INVOKE(std::declval<Fn>(), std::declval<ArgTypes>()...) is well formed when treated as an unevaluated operand, false otherwise (public static member constant) |
Member functions
operator bool
|
converts the object to bool, returns value (public member function) |
operator()
(C++14)
|
returns value (public member function) |
Member types
Type | Definition |
---|---|
value_type |
bool |
type |
std::integral_constant<bool, value> |
Notes
Feature-test macro | Value | Std | Feature |
---|---|---|---|
__cpp_lib_is_invocable |
201703L | (C++17) | std::is_invocable , std::invoke_result |
Examples
#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>);
}
See also
(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++11)
|
obtains a reference to its argument for use in unevaluated context (function template) |
(C++20)
|
specifies that a callable type can be invoked with a given set of argument types (concept) |
© cppreference.com
Licensed under the Creative Commons Attribution-ShareAlike Unported License v3.0.
https://en.cppreference.com/w/cpp/types/is_invocable