There is no independent "member function pointer" with the required property. The immediate task of the associated member function is to close:
Base * x = new Derived; auto f = [x]() { x->Base::Foo(); } f();
If your Base class is a special one-time use case and is under your control, you should probably add some kind of βaccept visitorβ function to it so that you can dynamically pass dynamic member members, for example x->accept(foo_caller); etc. Example in C ++ 14:
struct X { template <typename F> auto accept(F && f) { return [this, &f](auto &&... args) { return f(this, std::forward<decltype(args)>(args)...); }; } virtual void foo() const { std::cout << "base\n"; } };
Using:
void call_static_foo(X * p) { p->accept([](X * that){that->X::foo();}); }
source share