Boost C++ Libraries

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

PrevUpHomeNext

map

Description

map is an Associative Sequence of heterogeneous typed data elements. Each element is a key/data pair (see fusion::pair) where the key has no data (type only). Type identity is used to impose an equivalence relation on keys. A map may contain at most one element for each key. Membership testing and element key lookup has constant runtime complexity (see Overloaded Functions).

Header
#include <boost/fusion/container/map.hpp>
#include <boost/fusion/include/map.hpp>
#include <boost/fusion/container/map/map_fwd.hpp>
#include <boost/fusion/include/map_fwd.hpp>
Synopsis
template <
    typename T0 = unspecified
  , typename T1 = unspecified
  , typename T2 = unspecified
    ...
  , typename TN = unspecified
>
struct map;

For C++11 compilers, the variadic function interface has no upper bound.

For C++03 compilers, the variadic class interface accepts 0 to FUSION_MAX_MAP_SIZE elements, where FUSION_MAX_MAP_SIZE is a user definable predefined maximum that defaults to 10. Example:

map<pair<int, char>, pair<char, char>, pair<double, char> >

You may define the preprocessor constant FUSION_MAX_MAP_SIZE before including any Fusion header to change the default. Example:

#define FUSION_MAX_MAP_SIZE 20
Template parameters

Parameter

Description

Default

T0...TN

Element types

unspecified

Model of

Notation

M

A map type

m

An instance of map

e0...en

Heterogeneous key/value pairs (see fusion::pair)

s

A Forward Sequence

Expression Semantics

Semantics of an expression is defined only where it differs from, or is not defined in Forward Sequence and Associative Sequence.

Expression

Semantics

M()

Creates a map with default constructed elements.

M(e0, e1,... en)

Creates a map with element pairs e0...en.

M(s)

Copy constructs a map from a Forward Sequence s.

m = s

Assigns to a map, m, from a Forward Sequence s.

Example
typedef map<
    pair<int, char>
  , pair<double, std::string> >
map_type;

map_type m(
    make_pair<int>('X')
  , make_pair<double>("Men"));

std::cout << at_key<int>(m) << std::endl;
std::cout << at_key<double>(m) << std::endl;

PrevUpHomeNext