4 Jan
2007
4 Jan
'07
6:38 p.m.
Remigiusz Zukowski wrote: [...]
boost::function
f2 = boost::bind( &class::method, wptr_from( some_weak_ptr )); This works, but is unsafe - after get_pointer succesfully returns pointer to the object, the object is unlocked and can be deleted during class::method execution. Can anyone help me solving this problem ?
You can use
template<class T> shared_ptr<T> sptr_from( weak_ptr<T> const & wpt )
{
return shared_ptr<T>( wpt ); // throws on wpt.expired()
}
and then
boost::function