Boost logo

Boost :

From: Geoff Carlton (gcarlton_at_[hidden])
Date: 2005-06-23 19:42:41

I've just come across the intrusive list class in the sandbox. I've
been searching for a class like this for quite some time, but I never
thought to look through the boost sandbox area for it. I can finally
ditch my own partial implementation and use this nice alternative!

One issue I have seen with this class is that it destroys its nodes on
list destruction. Previously implementations I have seen instead
assert(empty()), leaving it up to the programmer to explicitly decide
what to do. In some cases it is indeed to clear the list, but in others
it may be to dethread the list and do something else entirely with the

An example is in the common pattern:
    array<particle> myPool;
    ilist<particle> activeList;
    ilist<particle> freeList;
Under this scheme the nodes were allocated in the array and then
threaded onto their respective lists. As such, automatic deletion would
cause a crash, and the programmer should instead just "leak" the list
back into the array.

Another disadvantage of the destructor calling clear() is that it
prevents the node class from having a private destructor. Objects may
need to be deleted via a manager class, however the destructor's clear()
will cause a compile error in this situation.

I find it interesting that under the "move sematics" C++0x proposal, the
ilist could be given move sematics and thus fit into STL containers. Is
there any ongoing interest in this class, and will it eventually make it
into the boost proper?


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