$include_dir="/home/hyper-archives/boost/include"; include("$include_dir/msg-header.inc") ?>
From: Peter Dimov (pdimov_at_[hidden])
Date: 2004-11-18 07:22:35
Peter Petrov wrote:
> Gennadiy Rozental <gennadiy.rozental <at> thomson.com> writes:
>
>> Here we do very simple (or complex,depends on point of view) trick
>> instead of above
>> Let say we have somewhere map<T*,shared_ptr<T>*> registry;
>>
>> if( registry[raw_ptr] == 0 ) {
>> t = shared_ptr<T>( raw_ptr )
>> registry.add( raw_ptr, &t );
>> }
>> else
>> t = *registry[raw_ptr];
>>
>>> // current shared_ptr implementation depends upon an internal
>>> pointer to a shared count.
>>> }
>>
>> Do I miss something important?
>
> What happens when some time after deserialization, one of the
> deserialized shared_ptr's is destroyed? Your "registry" has no way to
> know that and will still hold a shared_ptr referencing the same
> object, which is not correct.
The registry is not meant to outlive the deserialization process.