$include_dir="/home/hyper-archives/boost-users/include"; include("$include_dir/msg-header.inc") ?>
From: Robert Ramey (ramey_at_[hidden])
Date: 2006-11-22 14:03:12
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();