Function objects | |
| |
| |
| |
Old binders and adaptors |
| | | | | | (until C++17*)(until C++17*)(until C++17*)(until C++17*) | | |
| (until C++17*)(until C++17*) | (until C++17*)(until C++17*) |
| | (until C++17*)(until C++17*)(until C++17*)(until C++17*) | | |
|
template<class...ArgTypes>
typenamestd::result_of<T&(ArgTypes&&...)>::type
operator()( ArgTypes&&...args)const; | | (since C++11) (until C++17) |
template<class...ArgTypes>
std::invoke_result_t<T&, ArgTypes...>
operator()( ArgTypes&&...args)constnoexcept(/* see below */); | | (since C++17) (constexpr since C++20) |
| | |
Calls theCallable object, reference to which is stored, as if byINVOKE(get()
,std::forward<ArgTypes>(args)...). This function is available only if the stored reference points to aCallable object.
T
must be a complete type.
[edit]Parameters
args | - | arguments to pass to the called function |
[edit]Return value
The return value of the called function.
[edit]Exceptions
May throw implementation-defined exceptions. | (since C++11) (until C++17) |
| (since C++17) |
[edit]Example
Output:
reference to function calledbind expression called with 7 as the argumentlambda function called
[edit]Defect reports
The following behavior-changing defect reports were applied retroactively to previously published C++ standards.
DR | Applied to | Behavior as published | Correct behavior |
---|
LWG 3764 | C++17 | operator() is notnoexcept | propagatenoexcept |
[edit]See also
| accesses the stored reference (public member function)[edit] |