Boost Multi-index containers
The Boost Multi-index library actually provides a single generic container called multi_index_container
to store your objects and options to specify one or more indexes, using which you may look up the objects. Each index will use a different criterion on potentially different fields of the object. The indexes are defined and specified as template parameters to the container and this does make the container declaration a little daunting. But, this ultimately makes the container implementation tighter with a lot of compile-time optimizations. Indeed, the hardest part of using these containers is really getting their declaration right; so let us deconstruct a declaration of such a container of PersonEntry
objects:
Listing 6.2: Defining multi-index containers
1 #include <boost/multi_index_container.hpp> 2 #include <boost/multi_index/indexed_by.hpp> 3 #include <boost/multi_index/ordered_index.hpp> 4 #include <boost/multi_index/identity.hpp...