]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | .. Sequences/Intrinsic Metafunctions//value_type |
2 | ||
3 | value_type | |
4 | ========== | |
5 | ||
6 | Synopsis | |
7 | -------- | |
8 | ||
9 | .. parsed-literal:: | |
10 | ||
11 | template< | |
12 | typename Sequence | |
13 | , typename X | |
14 | > | |
15 | struct value_type | |
16 | { | |
17 | typedef |unspecified| type; | |
18 | }; | |
19 | ||
20 | ||
21 | ||
22 | Description | |
23 | ----------- | |
24 | ||
25 | Returns the |value| that would be used for element ``X`` in ``Sequence``. | |
26 | ||
27 | ||
28 | Header | |
29 | ------ | |
30 | ||
31 | .. parsed-literal:: | |
32 | ||
33 | #include <boost/mpl/value_type.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 | | ``Sequence`` | |Associative Sequence| | A sequence to query. | | |
49 | +---------------+---------------------------+-----------------------------------------------+ | |
50 | | ``X`` | Any type | The type to get the |value| for. | | |
51 | +---------------+---------------------------+-----------------------------------------------+ | |
52 | ||
53 | ||
54 | Expression semantics | |
55 | -------------------- | |
56 | ||
57 | For any |Associative Sequence| ``s``, and an artibrary type ``x``: | |
58 | ||
59 | ||
60 | .. parsed-literal:: | |
61 | ||
62 | typedef value_type<s,x>::type v; | |
63 | ||
64 | :Return type: | |
65 | A type. | |
66 | ||
67 | :Precondition: | |
68 | ``x`` can be put in ``s``. | |
69 | ||
70 | :Semantics: | |
71 | ``v`` is the |value| that would be used for ``x`` in ``s``. | |
72 | ||
73 | :Postcondition: | |
74 | If | |
75 | .. parsed-literal:: | |
76 | ||
77 | has_key< s,key_type<s,x>::type >::type | |
78 | ||
79 | then | |
80 | .. parsed-literal:: | |
81 | ||
82 | at< s,key_type<s,x>::type >::type | |
83 | ||
84 | is identical to ``value_type<s,x>::type``. | |
85 | ||
86 | ||
87 | ||
88 | Complexity | |
89 | ---------- | |
90 | ||
91 | Amortized constant time. | |
92 | ||
93 | ||
94 | Example | |
95 | ------- | |
96 | ||
97 | .. parsed-literal:: | |
98 | ||
99 | typedef value_type< map<>,pair<int,unsigned> >::type v1; | |
100 | typedef value_type< set<>,pair<int,unsigned> >::type v2; | |
101 | ||
102 | BOOST_MPL_ASSERT(( is_same< v1,unsigned > )); | |
103 | BOOST_MPL_ASSERT(( is_same< v2,pair<int,unsigned> > )); | |
104 | ||
105 | ||
106 | See also | |
107 | -------- | |
108 | ||
109 | |Associative Sequence|, |key_type|, |at|, |set|, |map| | |
110 | ||
111 | ||
112 |