std::function<R(Args...)>::operator() - cppreference.com (original) (raw)
| R operator()( Args... args ) const; | | (since C++11) | | ----------------------------------- | | ------------- |
Invokes the stored callable function target with the parameters args.
Effectively does INVOKE(f, std::forward<Args>(args)...), where f is the target object of *this.
[edit] Parameters
| args | - | parameters to pass to the stored callable function target |
|---|
[edit] Return value
None if R is void. Otherwise the return value of the invocation of the stored callable object.
[edit] Exceptions
Throws std::bad_function_call if *this does not store a callable function target, i.e. !*this == true.
[edit] Example
The following example shows how std::function can be passed to other functions by value. Also, it shows how std::function can store lambdas.
Possible output:
bad_function_call 1 2 42 Hi 42