std::is_callable, std::is_nothrow_callable

From cppreference.com
< cpp‎ | types
 
 
Utilities library
Type support (basic types, RTTI, type traits)
Dynamic memory management
Error handling
Program utilities
Variadic functions
Date and time
Function objects
(C++11)
Relational operators
Optional and any
(C++17)
(C++17)
Pairs and tuples
(C++11)
(C++17)
Swap, forward and move
(C++14)
(C++11)
(C++11)
Type operations
(C++11)
(C++17)
 
Type support
Basic types
Fundamental types
Fixed width integer types (C++11)
Numeric limits
C numeric limits interface
Runtime type information
Type traits
Type categories
(C++11)
(C++14)
(C++11)
(C++11)
(C++11)
(C++11)
(C++11)
(C++11)
(C++11)
(C++11)
(C++11)
(C++11)
(C++11)
(C++11)
(C++11)
Type properties
(C++11)
(C++11)
(C++11)
(C++11)
(C++11)
(C++14)
(C++11)
Type trait constants
Metafunctions
(C++17)
(C++17)
(C++17)
Supported operations
Relationships and property queries
(C++11)
(C++11)
(C++11)
(C++11)
(C++11)
(C++11)
is_callableis_nothrow_callable
(C++17)(C++17)
Type modifications
(C++11)(C++11)(C++11)
(C++11)(C++11)(C++11)
(C++11)
(C++11)
Type transformations
(C++11)
(C++11)
(C++11)
(C++11)
(C++17)
(C++11)
(C++11)
(C++11)
(C++11)
 
Defined in header <type_traits>
template <class, class R = void> struct is_callable; // not defined


template <class Fn, class... ArgTypes, class R>

struct is_callable<Fn(ArgTypes...), R>;
(1) (since C++17)
template <class, class R = void> struct is_nothrow_callable; // not defined


template <class Fn, class... ArgTypes, class R>

struct is_nothrow_callable<Fn(ArgTypes...), R>;
(2) (since C++17)
1) Determines whether Fn is callable with the arguments ArgTypes... and the result would be convertible to R. Formally, determines whether INVOKE(declval<Fn>(), declval<ArgTypes>()..., R) is well formed when treated as an unevaluated operand.
2) Determines whether Fn is callable with the arguments ArgTypes... and the result would be convertible to R (same as (1)), and that such call is known not to throw any exceptions.

Fn, R, and all types in ArgTypes can be any complete type, array of unknown bound, or (cv-qualified) void

Contents

[edit] Helper variable templates

Defined in header <type_traits>
template <class T, class R = void>
constexpr bool is_callable_v  = std::is_callable<T, R>::value;
(1) (since C++17)
template <class T, class R = void>
constexpr bool is_nothrow_callable_v = std::is_nothrow_callable<T, R>::value;
(2) (since C++17)

Inherited from std::integral_constant

Member constants

value
[static]
true if INVOKE(declval<Fn>(), declval<ArgTypes>()..., R) 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>

[edit] Notes

Version (1) of this trait may be implemented in terms of std::is_convertible and std::result_of.

[edit] Examples

[edit] See also

(C++17)
invokes any Callable object with given arguments
(function template)
(C++11)
deduces the return type of a function call expression
(class template)
(C++11)
obtains a reference to its argument for use in unevaluated context
(function template)