std::invoca...ar_invocable(3)
πΈ NAME πΈ
std::invocable,std::regular_invocable β and then, because why not, it says std::invocable,std::regular_invocable again. This is the page for std::invoca...ar_invocable(3), from the C++ Standard Libary manual (their spelling, not mine π).
β¨ Synopsis β¨
Okay so itβs defined in the header <concepts>, bestie. The synopsis is giving template-concept realness:
template< class F, class... Args >
concept invocable =
requires(F&& f, Args&&... args) {
std::invoke(std::forward<F>(f), std::forward<Args>(args)...);
/* not required to be equality-preserving */
};
template< class F, class... Args >
concept regular_invocable = std::invocable<F, Args...>;
Both of these are since C++20 β¨
The invocable concept specifies that a callable type F can be called with a set of arguments Args... using the function template std::invoke. Slay.
The regular_invocable concept adds to the invocable concept by requiring the invoke expression to be equality-preserving and not modify either the function object or the arguments. Periodt.
π¦ Notes π¦
The distinction between invocable and regular_invocable is purely semantic.
A random number generator may satisfy invocable but cannot satisfy regular_invocable (comical ones excluded). Not me side-eyeing the random number generators π
π See also π
is_invocableis_invocable_ris_nothrow_invocableis_nothrow_invocable_r
The whole little squad checks if a type can be invoked (as if by std::invoke) with the given argument types. Theyβre a class template, and theyβre C++17 π
π External links π
- A joke example of a random number generator that satisfies both
invocableandregular_invocable.
mwah π β source/version: http://cppreference.com; date: 2024.06.10; page: std::invoca...ar_invocable(3). Thatβs the footer, bestie, not me ignoring it π«Ά
π¦ 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