]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | .. Sequences/Intrinsic Metafunctions//erase_key |
2 | ||
3 | erase_key | |
4 | ========= | |
5 | ||
6 | Synopsis | |
7 | -------- | |
8 | ||
9 | .. parsed-literal:: | |
10 | ||
11 | template< | |
12 | typename AssocSeq | |
13 | , typename Key | |
14 | > | |
15 | struct erase_key | |
16 | { | |
17 | typedef |unspecified| type; | |
18 | }; | |
19 | ||
20 | ||
21 | ||
22 | Description | |
23 | ----------- | |
24 | ||
25 | Erases elements associated with the key ``Key`` in the |Extensible Associative Sequence| | |
26 | ``AssocSeq`` . | |
27 | ||
28 | Header | |
29 | ------ | |
30 | ||
31 | .. parsed-literal:: | |
32 | ||
33 | #include <boost/mpl/erase_key.hpp> | |
34 | ||
35 | ||
36 | Model of | |
37 | -------- | |
38 | ||
39 | |Tag Dispatched Metafunction| | |
40 | ||
41 | ||
42 | Parameters | |
43 | ---------- | |
44 | ||
45 | +---------------+-----------------------------------+-----------------------------------------------+ | |
46 | | Parameter | Requirement | Description | | |
47 | +===============+===================================+===============================================+ | |
48 | | ``AssocSeq`` | |Extensible Associative Sequence| | A sequence to erase elements from. | | |
49 | +---------------+-----------------------------------+-----------------------------------------------+ | |
50 | | ``Key`` | Any type | A key for the elements to be removed. | | |
51 | +---------------+-----------------------------------+-----------------------------------------------+ | |
52 | ||
53 | ||
54 | Expression semantics | |
55 | -------------------- | |
56 | ||
57 | For any |Extensible Associative Sequence| ``s``, and arbitrary type ``key``: | |
58 | ||
59 | ||
60 | .. parsed-literal:: | |
61 | ||
62 | typedef erase_key<s,key>::type r; | |
63 | ||
64 | :Return type: | |
65 | |Extensible Associative Sequence|. | |
66 | ||
67 | :Semantics: | |
68 | ``r`` is |concept-identical| and equivalent to ``s`` except that | |
69 | ``has_key<r,k>::value == false``. | |
70 | ||
71 | :Postcondition: | |
72 | ``size<r>::value == size<s>::value - 1``. | |
73 | ||
74 | ||
75 | ||
76 | Complexity | |
77 | ---------- | |
78 | ||
79 | Amortized constant time. | |
80 | ||
81 | ||
82 | Example | |
83 | ------- | |
84 | ||
85 | .. parsed-literal:: | |
86 | ||
87 | typedef map< pair<int,unsigned>, pair<char,long> > m; | |
88 | typedef erase_key<m,char>::type m1; | |
89 | ||
90 | BOOST_MPL_ASSERT_RELATION( size<m1>::type::value, ==, 1 ); | |
91 | BOOST_MPL_ASSERT(( is_same< at<m1,char>::type,void\_ > )); | |
92 | BOOST_MPL_ASSERT(( is_same< at<m1,int>::type,unsigned > )); | |
93 | ||
94 | ||
95 | See also | |
96 | -------- | |
97 | ||
98 | |Extensible Associative Sequence|, |erase|, |has_key|, |insert| | |
99 | ||
100 | ||
101 |