
18 Nov
2004
18 Nov
'04
9:27 a.m.
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.