std::is_inv..._invocable,(3)
πΈ NAME πΈ
Okay so bestie π«Ά we're looking at std::is_inv..._invocable,(3) from the C++ Standard Libary manual β and yes, "Libary" is literally how the header spells it, we don't fix, we appreciate π
. The NAME line is:
std::is_invocable,std::is_invocable_r,std::is_nothrow_invocable, - std::is_invocable,std::is_invocable_r,std::is_nothrow_invocable,
Also, std::is_nothrow_invocable_r shows up in the synopsis below, so keep your eyes peeled π. Every crumb stays.
β¨ Synopsis β¨
Defined in header <type_traits>.
template< class Fn, class... ArgTypes > (1) (since C++17)
struct is_invocable;
template< class R, class Fn, class... ArgTypes > (2) (since C++17)
struct is_invocable_r;
template< class Fn, class... ArgTypes > (3) (since C++17)
struct is_nothrow_invocable;
template< class R, class Fn, class... ArgTypes > (4) (since C++17)
struct is_nothrow_invocable_r;
The four overloads are giving very specific vibe checks:
- Determines whether
INVOKE(std::declval<Fn>(), std::declval<ArgTypes>()...)is well formed when treated as an unevaluated operand. - Determines whether
INVOKE<R>(std::declval<Fn>(), std::declval<ArgTypes>()...)is well formed when treated as an unevaluated operand. - 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. - 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.
π¨ Behavior is undefined ifFn,R, or any type in the parameter packArgTypesis not a complete type, is (possibly cv-qualified)void, or is an array of unknown bound.
π¨ 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.
π Member constants π
value[static] βtrueif (for overload (1))INVOKE(std::declval<Fn>(), std::declval<ArgTypes>()...)is well formed when treated as an unevaluated operand,falseotherwise. This is a public static member constant.
π Member functions π
operator boolβ converts the object tobool, returnsvalue(public member function)operator()β returnsvalue(C++14) (public member function)
π¦ Member types π¦
value_typeβbooltypeβstd::integral_constant<bool, value>
π Notes π
Feature-test macro tea:
- Macro:
__cpp_lib_is_invocable - Value:
201703L - Std:
(C++17) - Feature:
std::is_invocable, std::invoke_result
π₯ Examples π₯
// Run this code
#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 π
invokeβ invokes any Callable object with given argumentsinvoke_rβ and possibility to specify return type; tags from this cluster:(C++17)(since C++23)(C++23)(function template)result_ofβ deduces the result type of invoking a callable object withinvoke_resultβ a set of arguments; the original page's tags for this cluster are(C++11)(removed in C++20)(class template)(C++17)β yes, the line-wrapping is chaotic πdeclvalβ obtains a reference to its argument for use in unevaluated(C++11)context(function template)invocableβ specifies that a callable type can be invoked with a givenregular_invocableβ set of argument types;(C++20)(concept)
Bye bestie π this iconic page came from http://cppreference.com, dated 2024.06.10 β slay.
π¦ where this page comes from
- nixpkgs unstable: stdman 2024.07.05
- opensuse-leap 16.0: stdman 2024.07.05-bp160.1.9 Β· MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms