What construct should be used as surrogate for std::function<>
when C++11 is not available ?
The alternative should basically allow to access private member functions of one class from another class like in the example below (other features of std::function are not used). Class Foo is fixed and can not be changed much, I have only access to class Bar.
class Foo {
friend class Bar; // added by me, rest of the class is fixed
private:
void doStuffFooA(int i);
void doStuffFooB(int i);
};
class Bar {
public:
Bar( Foo foo, std::function< void (const Foo&, int) > func ) {
myFoo = foo;
myFooFunc = func;
};
private:
doStuffBar( const &Foo foo ) {
myFooFunc( foo, 3 );
}
Foo myFoo;
std::function< void (const Foo&, int) > myFooFunc;
}
int main() {
Foo foo(...);
Bar barA( foo, &Foo::doStuffFooA );
Bar barB( foo, &Foo::doStuffFooB );
...
}