22 Nov
2006
22 Nov
'06
7:23 p.m.
But now that I look at this, I'm wondering: Will t.lock() succeed if t is in an an "expired" state? Robert Ramey Robert Ramey wrote:
Very good. I'll make this tweak and check it in.
Robert Ramey
Peter Dimov wrote:
Mikko Vainio wrote:
Hi,
I'm trying to serialize an object of class X that has a member boost::weak_ptr< X >. The weak pointer may as well be empty and the object is still in valid state - at least in this context. The serialization code, however, tries to make a shared_ptr out of the weak_ptr, which throws a bad_weak_ptr when the weak_ptr is empty. Should the weak_ptr be checked for expired() before trying to make a shared_ptr of it?
The line
const boost::shared_ptr<T> sp(t);
should be
const boost::shared_ptr<T> sp = t.lock();