Boost logo

Boost :

From: Mathias Gaunard (mathias.gaunard_at_[hidden])
Date: 2007-03-16 12:52:45


Gennadiy Rozental wrote:
> "Mathias Gaunard" <mathias.gaunard_at_[hidden]> wrote in message
>> They're a more time and space efficient alternative for node-based
>> containers of pointers when you have the possibility of modifying the
>> type to make it into a node.
>
> Why? And how much? I need specific numbers.
>
>> So basically, if you have std::list<T*>, and you can modify T, then it
>> is more efficient to use std::ilist<T>.
>
> Why? how std::list<T*> prevent you to modify the pointed value and/or how
> does it affect performance?

Because std::list<T*> generates a node type that should look like that:

struct list_node
{
     T* value;
     list_node* next;
     list_node* prev;
};

This adds some indirection.

On the other hand, the intrusive technique doesn't allow to contain NULL
pointers, while std::list<T*> can.

> IOW this library promotes unsafe programming right?

Maybe it's not appropriately named, since they don't own anything.
Logically containers should own what they contain.

The technique could be adapted to something more like the pointer
containers (which are more similar to the original containers in how
they own their contents) though.


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk