std::ext STL (was: Re: design doc on alternative pointer support)
Phil Bouchard
philippe@fornux.com
Sat Aug 16 06:10:00 GMT 2008
"Phil Bouchard" <philippe@fornux.com> wrote in message
news:g81m4a$ddc$1@ger.gmane.org...
[...]
>> list:
>> n1 <-> n2 <-> n3 <-> n4
>>
>> stack:
>> n1 -> n2 -> n3 -> n4
>>
>> Now clear() iterates from n1 to n4 in both cases and deletes associates
>> nodes. But if we use smart pointers then if we'll get the entire
>> container
>> deleted by deleting n1. In the case of the list then it will be
>> different
>> because n2, n3 and n4 will not be deallocated just by deleting n1 (in
>> case
>> of shifted_ptr yes but not shared_ptr). So I'm still careful here and I
>> would like opening this subject before anything else.
>
> I forgot to say in the case of the list, if you set n1.next to 0 then you
> will not be able iterating on to n2, etc.
Ok it turns out if we delete the node pointed to by the "prev" pointer and
iterating forward with "next" then everything will be perfect...
-Phil
More information about the Libstdc++
mailing list