1.. Sequences/Classes//map |50 2 3map 4=== 5 6Description 7----------- 8 9``map`` is a |variadic|, `associative`__, `extensible`__ sequence of type pairs that 10supports constant-time insertion and removal of elements, and testing for membership. 11A ``map`` may contain at most one element for each key. 12 13__ `Associative Sequence`_ 14__ `Extensible Associative Sequence`_ 15 16Header 17------ 18 19+-------------------+-------------------------------------------------------+ 20| Sequence form | Header | 21+===================+=======================================================+ 22| Variadic | ``#include <boost/mpl/map.hpp>`` | 23+-------------------+-------------------------------------------------------+ 24| Numbered | ``#include <boost/mpl/map/map``\ *n*\ ``.hpp>`` | 25+-------------------+-------------------------------------------------------+ 26 27 28Model of 29-------- 30 31* |Variadic Sequence| 32* |Associative Sequence| 33* |Extensible Associative Sequence| 34 35 36Expression semantics 37-------------------- 38 39|In the following table...| ``m`` is an instance of ``map``, 40``pos`` is an iterator into ``m``, ``x`` and |p1...pn| are ``pair``\ s, and ``k`` is an arbitrary type. 41 42+---------------------------------------+-----------------------------------------------------------+ 43| Expression | Semantics | 44+=======================================+===========================================================+ 45| .. parsed-literal:: | ``map`` of elements |p1...pn|; see | 46| | |Variadic Sequence|. | 47| map<|p1...pn|> | | 48| map\ *n*\ <|p1...pn|> | | 49+---------------------------------------+-----------------------------------------------------------+ 50| .. parsed-literal:: | Identical to ``map``\ *n*\ ``<``\ |p1...pn|\ ``>``; | 51| | see |Variadic Sequence|. | 52| map<|p1...pn|>::type | | 53| map\ *n*\ <|p1...pn|>::type | | 54+---------------------------------------+-----------------------------------------------------------+ 55| ``begin<m>::type`` | An iterator pointing to the beginning of ``m``; | 56| | see |Associative Sequence|. | 57+---------------------------------------+-----------------------------------------------------------+ 58| ``end<m>::type`` | An iterator pointing to the end of ``m``; | 59| | see |Associative Sequence|. | 60+---------------------------------------+-----------------------------------------------------------+ 61| ``size<m>::type`` | The size of ``m``; see |Associative Sequence|. | 62+---------------------------------------+-----------------------------------------------------------+ 63| ``empty<m>::type`` | |true if and only if| ``m`` is empty; see | 64| | |Associative Sequence|. | 65+---------------------------------------+-----------------------------------------------------------+ 66| ``front<m>::type`` | The first element in ``m``; see | 67| | |Associative Sequence|. | 68+---------------------------------------+-----------------------------------------------------------+ 69| ``has_key<m,k>::type`` | Queries the presence of elements with the key ``k`` in | 70| | ``m``; see |Associative Sequence|. | 71+---------------------------------------+-----------------------------------------------------------+ 72| ``count<m,k>::type`` | The number of elements with the key ``k`` in ``m``; | 73| | see |Associative Sequence|. | 74+---------------------------------------+-----------------------------------------------------------+ 75| ``order<m,k>::type`` | A unique unsigned |Integral Constant| associated with | 76| | the key ``k`` in ``m``; see |Associative Sequence|. | 77+---------------------------------------+-----------------------------------------------------------+ 78| .. parsed-literal:: | The element associated with the key ``k`` in | 79| | ``m``; see |Associative Sequence|. | 80| at<m,k>::type | | 81| at<m,k,default>::type | | 82+---------------------------------------+-----------------------------------------------------------+ 83| ``key_type<m,x>::type`` | Identical to ``x::first``; see |Associative Sequence|. | 84+---------------------------------------+-----------------------------------------------------------+ 85| ``value_type<m,x>::type`` | Identical to ``x::second``; see |Associative Sequence|. | 86+---------------------------------------+-----------------------------------------------------------+ 87| ``insert<m,x>::type`` | A new ``map``, ``t``, equivalent to ``m`` except that | 88| | :: | 89| | | 90| | at< t, key_type<m,x>::type >::type | 91| | | 92| | is identical to ``value_type<m,x>::type``. | 93+---------------------------------------+-----------------------------------------------------------+ 94| ``insert<m,pos,x>::type`` | Equivalent to ``insert<m,x>::type``; ``pos`` is ignored. | 95+---------------------------------------+-----------------------------------------------------------+ 96| ``erase_key<m,k>::type`` | A new ``map``, ``t``, equivalent to ``m`` except that | 97| | ``has_key<t, k>::value == false``. | 98+---------------------------------------+-----------------------------------------------------------+ 99| ``erase<m,pos>::type`` | Equivalent to ``erase<m, deref<pos>::type >::type``. | 100+---------------------------------------+-----------------------------------------------------------+ 101| ``clear<m>::type`` | An empty ``map``; see |clear|. | 102+---------------------------------------+-----------------------------------------------------------+ 103 104 105Example 106------- 107 108.. parsed-literal:: 109 110 typedef map< 111 pair<int,unsigned> 112 , pair<char,unsigned char> 113 , pair<long_<5>,char[17]> 114 , pair<int[42],bool> 115 > m; 116 117 BOOST_MPL_ASSERT_RELATION( size<m>::value, ==, 4 ); 118 BOOST_MPL_ASSERT_NOT(( empty<m> )); 119 120 BOOST_MPL_ASSERT(( is_same< at<m,int>::type, unsigned > )); 121 BOOST_MPL_ASSERT(( is_same< at<m,long_<5> >::type, char[17] > )); 122 BOOST_MPL_ASSERT(( is_same< at<m,int[42]>::type, bool > )); 123 BOOST_MPL_ASSERT(( is_same< at<m,long>::type, void\_ > )); 124 125 126See also 127-------- 128 129|Sequences|, |Variadic Sequence|, |Associative Sequence|, |Extensible Associative Sequence|, |set|, |vector| 130 131 132.. copyright:: Copyright � 2001-2009 Aleksey Gurtovoy and David Abrahams 133 Distributed under the Boost Software License, Version 1.0. (See accompanying 134 file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 135