Boost logo

Boost :

From: Stephen C. Gilardi (squeegee_at_[hidden])
Date: 2000-01-29 08:39:17

> > if (left == this)
> > delete ptr;

I could be wrong, but I don't think this is a correct test for
uniqueness. It happens to work in the example test program, but in
real life these linked pointers can be created and destroyed in any
order. It's true that the list always grows by adding elements to
the right of existing elements, but the elements can be removed in
any order, including having the leftmost element removed before the
others. (Suppose the linked pointer are part of heap-based objects.)

If the only test for uniqueness is "if (left == this)", then when the
leftmost element is removed, the underlying (pointed to) object is
deleted. That's wrong because there may still be other
linked_pointers pointing to it.

I think the test has to be "if (left == this && right == this)" or
something equivalent.


Boost list run by bdawes at, gregod at, cpdaniel at, john at