Boost  v1.57.0
doxygen for www.boost.org
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
boost::bimaps::tags Namespace Reference

A light non-invasive idiom to tag a type. More...

Namespaces

 support
 Metafunctions to work with tagged types.
 

Classes

struct  tagged
 The tag holder. More...
 

Detailed Description

A light non-invasive idiom to tag a type.

There are a lot of ways of tagging a type. The standard library for example defines tags (empty structs) that are then inherited by the tagged class. To support built-in types and other types that simple cannot inherit from the tag, the standard builds another level of indirection. An example of this is the type_traits metafunction. This approach is useful if the tags are intended to be used in the library internals, and if the user does not have to create new tagged types often.

Boost.MultiIndex is an example of a library that defines a tagged idiom that is better suited to the user. As an option, in the indexed by declaration of a multi-index container a user can attach a tag to each index, so it can be referred by it instead of by the index number. It is a very user friendly way of specifying a tag but is very invasive from the library writer's point of view. Each index must now support this additional parameter. Maybe not in the case of the multi-index container, but in simpler classes the information of the tags is used by the father class rather than by the tagged types.

tagged is a light non-invasive idiom to tag a type. It is very intuitive and user-friendly. With the use of the defined metafunctions the library writer can enjoy the coding too.