##### cppreference.com

##### Search

Create account

##### Namespaces

- Page
- Discussion

##### Variants

##### Views

- View
- Edit
- History

##### Actions

# std::is_invocable, std::is_invocable_r, std::is_nothrow_invocable, std::is_nothrow_invocable_r

From cppreference.com
< cpp‎ | types

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)

1) Determines whether `Fn` can be invoked with the arguments `ArgTypes...`. Formally, determines whether `INVOKE(declval<Fn>(), declval<ArgTypes>()...)` is well formed when treated as an unevaluated operand, where `INVOKE` is the operation defined in `Callable`.
2) Determines whether `Fn` can be invoked with the arguments `ArgTypes...` to yield a result that is convertible to `R`. Formally, determines whether `INVOKE<R>(declval<Fn>(), declval<ArgTypes>()...)` is well formed when treated as an unevaluated operand, where `INVOKE` is the operation defined in `Callable`
3) Determines whether `Fn` is callable with the arguments `ArgTypes...` (same as (1)), and that such call is known not to throw any exceptions.
4) Determines whether `Fn` can be invoked with the arguments `ArgTypes...` to yield a result that is convertible to `R` (same as (2)), and that such call 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.

### [edit] Helper variable templates

Defined in header `<type_traits>` |  |
template <class Fn, class... ArgTypes> inline constexpr bool is_invocable_v = std::is_invocable<Fn, ArgTypes...>::value; | (1) | (since C++17)
template <class R, class Fn, class... ArgTypes> inline constexpr bool is_invocable_r_v = std::is_invocable_r<R, Fn, ArgTypes...>::value; | (2) | (since C++17)
template <class Fn, class... ArgTypes> inline constexpr bool is_nothrow_invocable_v = std::is_nothrow_invocable<Fn, ArgTypes...>::value; | (3) | (since C++17)
template <class R, class Fn, class... ArgTypes> inline constexpr bool is_nothrow_invocable_r_v = std::is_nothrow_invocable_r<R, Fn, ArgTypes...>::value; | (4) | (since C++17)

[edit]

## Inherited from std::integral_constant

### Member constants

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

### [edit] Examples

| This section is incomplete Reason: no example

### [edit] See also

invoke (C++17) | invokes any `Callable` object with given arguments (function template) [edit]
result_of invoke_result (C++11)(deprecated in C++17)(C++17) | deduces the result type of invoking a callable object with a set of arguments (class template) [edit]
declval (C++11) | obtains a reference to its argument for use in unevaluated context (function template) [edit]

Retrieved from "http://en.cppreference.com/mwiki/index.php?title=cpp/types/is_invocable&oldid=91108"
Category:

- Todo no example