| Type traits | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Compile-time rational arithmetic | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Compile-time integer sequences | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
(C++14) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Defined in header <type_traits> | ||
template<class Fn,class...ArgTypes> struct is_invocable; | (1) | (since C++17) |
template<class R,class Fn,class...ArgTypes> struct is_invocable_r; | (2) | (since C++17) |
template<class Fn,class...ArgTypes> struct is_nothrow_invocable; | (3) | (since C++17) |
template<class R,class Fn,class...ArgTypes> struct is_nothrow_invocable_r; | (4) | (since C++17) |
IfFn, R or any type in the parameter packArgTypes 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.
Contents |
Defined in header <type_traits> | ||
template<class Fn,class...ArgTypes> inlineconstexprbool is_invocable_v= | (1) | (since C++17) |
template<class R,class Fn,class...ArgTypes> inlineconstexprbool is_invocable_r_v= | (2) | (since C++17) |
template<class Fn,class...ArgTypes> inlineconstexprbool is_nothrow_invocable_v= | (3) | (since C++17) |
template<class R,class Fn,class...ArgTypes> inlineconstexprbool is_nothrow_invocable_r_v= | (4) | (since C++17) |
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) |
operator bool | converts the object tobool, returnsvalue (public member function) |
operator() (C++14) | returnsvalue (public member function) |
| Type | Definition |
value_type | bool |
type | std::integral_constant<bool, value> |
| Feature-test macro | Value | Std | Feature |
|---|---|---|---|
__cpp_lib_is_invocable | 201703L | (C++17) | std::is_invocable,std::invoke_result |
#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>);}
(C++17)(C++23) | invokes anyCallable object with given argumentsand 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] |
(C++20) | specifies that a callable type can be invoked with a given set of argument types (concept)[edit] |