...one of the most highly
regarded and expertly designed C++ library projects in the
world. — Herb Sutter and Andrei
This is a very interesting point of the design. The framework introduced in std::set theory permits the management of the different constraints with a very simple and conceptual approach. It is easy both to remember and to learn. The idea here is to allow the user to specify the collection type of each key directly. In order to implement this feature, we have to solve two problems:
multi_index_containercore now depends on the collection type used for each key.
Boost.Bimap relies heavily on Boost.MPL to implement all of the metaprogramming
necessary to make this framework work. By default, if the user does not specify
the kind of the set, a
The constraints of the bimap set view are another very important feature. In general, Boost.Bimap users will base the set view type on one of the two collection types of their keys. It may be useful however to give this set other constraints or simply to order it differently. By default, Boost.Bimap bases the collection type of relations on the left collection type, but the user may choose between:
In the first two cases, there are only two indices in the
and for this reason, these are the preferred options. The implementation
uses further metaprogramming to define a new index if necessary.
The idea of using tags instead of the
idiom is very appealing since code that uses it is more readable. The only
cost is compile time. boost/bimap/tagged is the implementation
of a non-invasive tagged idiom. The
relation class is
built in such a way that even when the user uses tags, the
idiom continues to work. This is good since an user can start tagging even
before completing the coding of the algorithm, and the untagged code continues
to work. The development becomes a little more complicated when user-defined
tags are included, but there are many handy metafunctions defined in the
tagged idiom that help to keep things simple enough.