Boost logo

Boost :

From: Maxim Yegorushkin (maxim.yegorushkin_at_[hidden])
Date: 2005-08-04 10:03:47

[multi_index] feature request

In my code I often use collections of noncopyable objects and yet I need
to have
them indexed. The usual solution is to store pointers to the objects in the
index (be it a std::set/map or boost::multi_index). This leads to two
allocations: the first for the object and the second for the index node.
For me
it would be more natural and effective to embed the index node in the
object, so
that the container is obviated from allocating nodes and only maintains
indexes. This also would make all container operations nothrow, since
insertion and removal requires only node pointer manipulations and using
comparer object which is typically nothrow.

In my work I use my own intrusive_list which has proved itself quite
useful and
effective. The syntax is:

     struct noncopyable_object;
     typedef intrusive_list<noncopyable_object> list;
     struct noncopyable_object
         : list::node // embed the list node in the class
         // ...

Will such a feature ever make it to multi_index?

Maxim Yegorushkin

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