From cppreference, I found that:
Class template std::function is a general-purpose polymorphic function wrapper. Instances of std::function can store, copy, and invoke any Callable target -- functions, lambda expressions, bind expressions, or other function objects, as well as pointers to member functions and pointers to data members.
I cannot see why a std::function
should be able to store such a pointer and I've never heard before about that feature.
Is it really possible, I missed something or that's an error in the documentation?
How should the operator()
behave in such a case?
As from the documentation:
Invokes the stored callable function target with the parameters args.
Anyway, there is no stored callable function target to invoke here. Am I wrong?
To be honest, I cannot even figure out what's the right syntax for such a function, otherwise I'd have written an example to test it.
How could the following template be used to define a pointer to data member?
template< class R, class... Args >
class function<R(Args...)>
std::bind
can be assigned to astd::function
. – Gassingbind
returns a callable object, it's fine. – Roquefort