Boost C++ Libraries Home Libraries People FAQ More

PrevUpHomeNext

map

Description

map is an Associative Sequence of heteregenous 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/sequence/container/map.hpp>
Synopsis
template <
    typename T0 = unspecified
  , typename T1 = unspecified
  , typename T2 = unspecified
    ...
  , typename TN = unspecified
>
struct map;

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-type
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 Random Access 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<int>(m) << std::endl;
std::cout << at<double>(m) << std::endl;
Copyright © 2001-2005 Joel de Guzman, Dan Marsden

PrevUpHomeNext