In this code, the line (iter->second)(); calls the function reset(new childClass()). Is this correct ?
If this is the case, it is called on whi
the
line (iter->second)();calls the functionreset(new childClass()). Is this correct?
No, it invokes reset(). If you want it to be called as reset(new childClass()), you need to pass new childClass() to boost::bind as argument like
boost::bind( static_cast<void( boost::shared_ptr<BaseClass>::* )(BaseClass*)>(
&boost::shared_ptr<BaseClass>::reset ),
boost::shared_ptr<BaseClass>(new childClass() ),
new childClass() )
Note that new childClass() itself is evaluated when boost::bind is invoked, not the functor is invoked.
Or you can add a placeholder, and pass new childClass() when call the functor.
it is called on which object ?
It's called on the object copied from the argument passed to boost::bind, i.e. boost::shared_ptr<BaseClass>(new childClass() ).