Inside the class, outside the class, that's not really important to the use of std::bind
. A non-static member function must be called with a valid object of the class it is a member of. std::bind
considers that object to be the first argument it is given after the callable, plain and simple.
So you can do it as you noted, inside the class, and supply the "current" object as the first bound argument.
Or you can do it outside the class, if the member is accessible, and supply some object (as @Scheff pointed out):
MyClass myClass;
using namespace std::placeholders;
auto callback = std::bind(&MyClass::afterCompleteCallback, &myClass, _1);
You may even choose not to bind the object at all, and leave a placeholder for that as well:
MyClass myClass;
using namespace std::placeholders;
auto callback = std::bind(&MyClass::afterCompleteCallback, _1, _2);
callback(myClass, /*Other arg*/);
Also, and despite the fact you tagged c++11. With the changes to lambdas in c++14, there really is no reason to use std::bind
anymore.