Boost C++ Libraries of the most highly regarded and expertly designed C++ library projects in the world. Herb Sutter and Andrei Alexandrescu, C++ Coding Standards

This is the documentation for an old version of Boost. Click here to view this page for the latest version.

Bimap and Boost

Bimap and MultiIndex
Boost Libraries that work well with Boost.Bimap

MISC - Multi-Index Specialized Containers

Let's be generic, construct frameworks, describe the world in an unified way...

No!, it is better to be specialized, design easy-to-use components, offer plug-and-play objects...

Why not take advantage of the best of both worlds?


With Boost.Bimap, you can build associative containers in which both types can be used as key. There is a library in Boost that already allows the creation of this kind of container: Boost.MultiIndex. It offers great flexibility and lets you construct almost any container that you could dream of. The framework is very clean. You migh want to read this library's tutorial to learn about the power that has been achieved.

But generality comes at a price: the interface that results might not be the best for every specialization. People may end up wrapping a B.MI container in its own class every time they want to use it as a bidirectional map. Boost.Bimap takes advantage of the narrower scope to produce a better interface for bidirectional maps [2] . There is no learning curve if you know how to use standard containers. Great effort was put into mapping the naming scheme of the STL to Boost.Bimap. The library is designed to match the common STL containers.

Boost.MultiIndex is, in fact, the core of the bimap container.

However, Boost.Bimap do not aim to tackle every problem with two indexed types. There exist some problems that are better modelled with Boost.MultiIndex.

You can also read Additional Information for more information about the relation of this two libraries.

[2] In the same fashion, Boost.MRU will allow the creation of most recent updated aware containers, hiding the complexity of Boost.MultiIndex.