On Thu, Apr 25, 2019 at 10:25 AM Farid Mehrabi via SG14 <sg14@lists.isocpp.org> wrote:
Is there any interest enabling deferred call semantics for intrinsic method binding with native syntax:
std::function<signature> fn=instance.method;
IMHO  due to spec of member function pointers, std::bind is expensive in terms of memory. It also has the downside of too verbose syntax which is too complicated for training novice programmers and lacks the ability to cover  early bound base methods:
auto fn=instance.base::method;
And lambdas cannot help if code repetition is intended because one would need to forward all arguments:
auto lam=[&instance](Args...)
{return instance.method(params...);};
Thanks in advance.

This sounds very similar to the "lifting syntax" proposal briefly mentioned here:
and solidly proposed here:

Notice that `instance.method` is already an overload set:

struct S {
    void method();
    int method(int);
    static void smethod();
    static int smethod(int);
};
S instance;
int main() {
    std::function<int(int)> f = instance.method; // fails, for the same reason that
    std::function<int(int)> g = S::smethod;  // also fails
}

So what you're looking for, at the moment (C++17 and presumably C++2a) is currently spelled

#define FWD(...) std::forward<decltype(__VA_ARGS__)>(__VA_ARGS__)

#define LIFT(X) [&](auto &&... args) \
    noexcept(noexcept(X(FWD(args)...)))  \
    -> decltype(X(FWD(args)...)) \
{  \
    return X(FWD(args)...); \
}

which is the same thing Simon Brand gives in his blog post, but with one additional ampersand (bolded above).

int main() {
    std::function<int(int)> f = LIFT(instance.method); // OK
    std::function<int(int)> g = LIFT(S::smethod);  // OK
}

HTH,
–Arthur