The effect of a call to the function call operator of std::function<R(ArgTypes...)>
:
R operator()(ArgTypes... args) const
is equivalent to (§ 20.9.11.2.4 [func.wrap.func.inv]/p1):
INVOKE<R>(f, std::forward<ArgTypes>(args)...)
whose definition includes the following bullet (§ 20.9.2 [func.require]/p1):
Define INVOKE(f, t1, t2, …, tN) as follows:
[…]
1.3 —
t1.*f
whenN == 1
andf
is a pointer to member data of a classT
andt1
is an object of typeT
or a
reference to an object of typeT
or a reference to an object of a type derived fromT
;
then, when f
is a pointer to a data member stored in an internal invoker of a std::function
, then the std::function
itself should define a single argument, e.g.:
std::function<int(std::pair<int,int>)> f = &std::pair<int,int>::first;
f(std::make_pair(1, 2));
DEMO