template<class R, class T, class ObjT, class … Arg>
unspecified mem_fn(R T::* pm, ObjT&& obj);
//Here introduce names OjbTD for std::decay_t<ObjT> and objd for object constructed from std::forward<ObjT>(obj);
Requires: std::is_constructible<ObjTD, ObjT>::value is true.
Returns: A simple call wrapper (20.10.1) fn such that the expression fn(a1, ..., aN) is equivalent to INVOKE(pm, <del>obj</del> <ins>objd</ins>, a1,…aN).
Throws: Nothing unless construction of objd throws.
Remarks: //Info that returned object should be moveable and copyable if ObjTD is copyable.
The revised version has an improved implementation, which allows to pass objects, pointers to objects and smart pointers as the second parameter to mem_fn.
Tomasz,Well spotted. I have put a revised version, which includes the support for unique pointers and reference wrappers for the second parameter.Mikhail.
Thanks for the proposals. The Library Evolution group in Chicago
reviewed mem_fn and concluded that it's generally not worth extending
the callable wrappers, and that users should just use lambdas in
nearly all cases. C++14's generic lambdas with variadic captures make
this an even better tradeoff (note, I didn't compile this):
double r = integrate
([&a](const auto&... args) { return a.fa(args...);},
x1, x2, y1, y2, z1, z2, a1, a2, b1, b2);
return [=](auto&& ... ts) { // OK: ts is a function parameter pack
printer(std::forward<decltype(ts)>(ts)...);
...
The decltype(ts), not decltype(auto), otherwise the type is not clear.
As for the return -> decltype(auto), it was always optional for lambdas, especially it there is one return statement.
The decltype(ts), not decltype(auto), otherwise the type is not clear.
As for the return -> decltype(auto), it was always optional for lambdas, especially it there is one return statement=