]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | .. Iterators/Iterator Metafunctions//deref |50 |
2 | ||
3 | deref | |
4 | ===== | |
5 | ||
6 | Synopsis | |
7 | -------- | |
8 | ||
9 | .. parsed-literal:: | |
10 | ||
11 | template< | |
12 | typename Iterator | |
13 | > | |
14 | struct deref | |
15 | { | |
16 | typedef |unspecified| type; | |
17 | }; | |
18 | ||
19 | ||
20 | ||
21 | Description | |
22 | ----------- | |
23 | ||
24 | Dereferences an iterator. | |
25 | ||
26 | ||
27 | Header | |
28 | ------ | |
29 | ||
30 | .. parsed-literal:: | |
31 | ||
32 | #include <boost/mpl/deref.hpp> | |
33 | ||
34 | ||
35 | ||
36 | Parameters | |
37 | ---------- | |
38 | ||
39 | +---------------+---------------------------+-----------------------------------+ | |
40 | | Parameter | Requirement | Description | | |
41 | +===============+===========================+===================================+ | |
42 | | ``Iterator`` | |Forward Iterator| | The iterator to dereference. | | |
43 | +---------------+---------------------------+-----------------------------------+ | |
44 | ||
45 | ||
46 | Expression semantics | |
47 | -------------------- | |
48 | ||
49 | For any |Forward Iterator|\ s ``iter``: | |
50 | ||
51 | ||
52 | .. parsed-literal:: | |
53 | ||
54 | typedef deref<iter>::type t; | |
55 | ||
56 | :Return type: | |
57 | A type. | |
58 | ||
59 | :Precondition: | |
60 | ``iter`` is dereferenceable. | |
61 | ||
62 | :Semantics: | |
63 | ``t`` is identical to the element referenced by ``iter``. If ``iter`` is | |
64 | a user-defined iterator, the library-provided default implementation is | |
65 | equivalent to | |
66 | ||
67 | .. parsed-literal:: | |
68 | ||
69 | typedef iter::type t; | |
70 | ||
71 | ||
72 | ||
73 | ||
74 | Complexity | |
75 | ---------- | |
76 | ||
77 | Amortized constant time. | |
78 | ||
79 | ||
80 | Example | |
81 | ------- | |
82 | ||
83 | .. parsed-literal:: | |
84 | ||
85 | typedef vector<char,short,int,long> types; | |
86 | typedef begin<types>::type iter; | |
87 | ||
88 | BOOST_MPL_ASSERT(( is_same< deref<iter>::type, char > )); | |
89 | ||
90 | ||
91 | See also | |
92 | -------- | |
93 | ||
94 | |Iterators|, |begin| / |end|, |next| | |
95 | ||
96 | ||
97 |