std::function<R(Args...)>::target - cppreference.com (original) (raw)
| template< class T > T* target() noexcept; | (1) | (since C++11) |
|---|---|---|
| template< class T > const T* target() const noexcept; | (2) | (since C++11) |
Returns a pointer to the stored callable function target.
[edit] Parameters
(none)
[edit] Return value
A pointer to the stored function if target_type() == typeid(T), otherwise a null pointer.
[edit] Example
Output:
test function: it is plus test function: it is minus test function: it is the function f test function: it is the function g
[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 2591 | C++11 | the behavior is undefined if T is not Callable | behavior is defined (always returns nullptr) |