我想std::bind从一个私有基类的成员函数using,在派生类中使用-declaration "public" .调用函数直接工作,但似乎绑定或使用成员函数指针不编译:
#include <functional>
struct Base {
void foo() { }
};
struct Derived : private Base {
using Base::foo;
};
int main(int, char **)
{
Derived d;
// call member function directly:
// compiles fine
d.foo();
// call function object bound to member function:
// no matching function for call to object of type '__bind<void (Base::*)(), Derived &>'
std::bind(&Derived::foo, d)();
// call via pointer to member function:
// cannot cast 'Derived' to its private …Run Code Online (Sandbox Code Playgroud)