...one of the most highly
regarded and expertly designed C++ library projects in the
world.
— Herb Sutter and Andrei
Alexandrescu, C++
Coding Standards
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).
#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>
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
Parameter |
Description |
Default |
---|---|---|
|
Element types |
unspecified |
Notation
M
A map
type
m
An instance of map
e0
...en
Heterogeneous key/value pairs (see fusion::pair
)
s
Semantics of an expression is defined only where it differs from, or is not defined in Forward Sequence and Associative Sequence.
Expression |
Semantics |
---|---|
|
Creates a map with default constructed elements. |
|
Creates a map with element pairs |
|
Copy constructs a map from a Forward
Sequence |
|
Assigns to a map, |
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;