C++ named requirements: Callable
From cppreference.com
C++
Feature test macros (C++20)
Concepts library (C++20)
Metaprogramming library (C++11)
Ranges library (C++20)
Filesystem library (C++17)
Concurrency support library (C++11)
Execution control library (C++26)
C++ named requirements
(C++11)
(C++11)
(C++11)
(C++11)
(C++11)
(C++11)
(C++11)
(C++11)
Callable
(C++17)
(C++11)
(C++11)
(C++11)
(C++11)
(C++11)
(C++11)
(C++17)
(C++20)
(C++20)
(C++20)
(C++11)
(C++11)
(C++11)
(C++11)
(C++11)
(C++11)
(C++11)
(C++11)
(C++14)
(C++14)
(C++11)
(C++11)
(C++17)
(C++14)
(C++20)
(C++20)
(C++23)
(C++23)
(C++23)
(C++11)
(C++11)
(C++11)
(C++11)
(C++11)
A Callable type is a type for which the INVOKE and INVOKE<R> operations (used by, e.g., std::function , std::bind , and std::thread::thread ) are applicable.
INVOKE
can be performed explicitly using the library function std::invoke .
INVOKE<R>
can be performed explicitly using the library function std::invoke_r.
[edit] Requirements
The type T
satisfies Callable if
Given
-
f
, an object of typeT
, -
ArgTypes
, suitable list of argument types, -
R
, suitable return type.
The following expressions must be valid:
Expression | Requirements |
---|---|
INVOKE<R> (f, std::declval <ArgTypes>()...) | The expression is well-formed in unevaluated context. |
[edit] Notes
Pointers to data members are Callable, even though no function calls take place.
[edit] Standard library
In addition, the following standard library facilities accept any Callable type (not just FunctionObject):
(C++23)
(class template) [edit]
(C++26)
(class template) [edit]
(C++20)(C++23)
(function template) [edit]
(C++11)(removed in C++20)(C++17)
(class template) [edit]
(C++11)
(function template) [edit]
(C++11)
(function template) [edit]
(C++11)
(class template) [edit]
[edit] See also
checks if a type can be invoked (as if by std::invoke ) with the given argument types
(class template) [edit]
(class template) [edit]
(C++20)
(concept) [edit]
(C++17)(C++23)
(function template) [edit]