CClass inst;
boost::function<bool(int)> func = boost::bind(&CClass::Foo, &inst, _1);
In this situation, I want to access inst's pointer(&inst) or address from "func" like below.
CClass* pInstance = func.obj_ptr; (This is just a form that I want)
How can I do?
There is a way, with the use of
boost::function::target()
template method. But sinceboost::bind
return unspecified type, witch do not yet provide a way to access arguments, you will need to write your own binder functor. Here is some example:So now you can access:
Same as with the
boost::any
there is no way to have polymorphic access witch thetarget
template method.