blob: f81ccd21a5b79b3c06458cc5def89a7ee6a118b6 [file] [log] [blame]
Brian Silverman59623332018-08-04 23:36:56 -07001.. Copyright David Abrahams 2006. Distributed under the Boost
2.. Software License, Version 1.0. (See accompanying
3.. file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
4
5::
6
7 template<typename IteratorTuple>
8 class zip_iterator
9 {
10
11 public:
12 typedef /* see below */ reference;
13 typedef reference value_type;
14 typedef value_type* pointer;
15 typedef /* see below */ difference_type;
16 typedef /* see below */ iterator_category;
17
18 zip_iterator();
19 zip_iterator(IteratorTuple iterator_tuple);
20
21 template<typename OtherIteratorTuple>
22 zip_iterator(
23 const zip_iterator<OtherIteratorTuple>& other
24 , typename enable_if_convertible<
25 OtherIteratorTuple
26 , IteratorTuple>::type* = 0 // exposition only
27 );
28
29 const IteratorTuple& get_iterator_tuple() const;
30
31 private:
32 IteratorTuple m_iterator_tuple; // exposition only
33 };
34
35 template<typename IteratorTuple>
36 zip_iterator<IteratorTuple>
37 make_zip_iterator(IteratorTuple t);
38
39
40The ``reference`` member of ``zip_iterator`` is the type of the tuple
41made of the reference types of the iterator types in the ``IteratorTuple``
42argument.
43
44The ``difference_type`` member of ``zip_iterator`` is the ``difference_type``
45of the first of the iterator types in the ``IteratorTuple`` argument.
46
47The ``iterator_category`` member of ``zip_iterator`` is convertible to the
48minimum of the traversal categories of the iterator types in the ``IteratorTuple``
49argument. For example, if the ``zip_iterator`` holds only vector
50iterators, then ``iterator_category`` is convertible to
51``boost::random_access_traversal_tag``. If you add a list iterator, then
52``iterator_category`` will be convertible to ``boost::bidirectional_traversal_tag``,
53but no longer to ``boost::random_access_traversal_tag``.
54
55
56``zip_iterator`` requirements
57...................................
58
59All iterator types in the argument ``IteratorTuple`` shall model Readable Iterator.
60
61
62``zip_iterator`` models
63.............................
64
65The resulting ``zip_iterator`` models Readable Iterator.
66
67The fact that the ``zip_iterator`` models only Readable Iterator does not
68prevent you from modifying the values that the individual iterators point
69to. The tuple returned by the ``zip_iterator``'s ``operator*`` is a tuple
70constructed from the reference types of the individual iterators, not
71their value types. For example, if ``zip_it`` is a ``zip_iterator`` whose
72first member iterator is an ``std::vector<double>::iterator``, then the
73following line will modify the value which the first member iterator of
74``zip_it`` currently points to:
75
76::
77
78 zip_it->get<0>() = 42.0;
79
80
81Consider the set of standard traversal concepts obtained by taking
82the most refined standard traversal concept modeled by each individual
83iterator type in the ``IteratorTuple`` argument.The ``zip_iterator``
84models the least refined standard traversal concept in this set.
85
86``zip_iterator<IteratorTuple1>`` is interoperable with
87``zip_iterator<IteratorTuple2>`` if and only if ``IteratorTuple1``
88is interoperable with ``IteratorTuple2``.
89
90
91
92``zip_iterator`` operations
93.................................
94
95In addition to the operations required by the concepts modeled by
96``zip_iterator``, ``zip_iterator`` provides the following
97operations.
98
99
100``zip_iterator();``
101
102:Returns: An instance of ``zip_iterator`` with ``m_iterator_tuple``
103 default constructed.
104
105
106``zip_iterator(IteratorTuple iterator_tuple);``
107
108:Returns: An instance of ``zip_iterator`` with ``m_iterator_tuple``
109 initialized to ``iterator_tuple``.
110
111
112::
113
114 template<typename OtherIteratorTuple>
115 zip_iterator(
116 const zip_iterator<OtherIteratorTuple>& other
117 , typename enable_if_convertible<
118 OtherIteratorTuple
119 , IteratorTuple>::type* = 0 // exposition only
120 );
121
122:Returns: An instance of ``zip_iterator`` that is a copy of ``other``.
123:Requires: ``OtherIteratorTuple`` is implicitly convertible to ``IteratorTuple``.
124
125
126``const IteratorTuple& get_iterator_tuple() const;``
127
128:Returns: ``m_iterator_tuple``
129
130
131``reference operator*() const;``
132
133:Returns: A tuple consisting of the results of dereferencing all iterators in
134 ``m_iterator_tuple``.
135
136
137``zip_iterator& operator++();``
138
139:Effects: Increments each iterator in ``m_iterator_tuple``.
140:Returns: ``*this``
141
142
143``zip_iterator& operator--();``
144
145:Effects: Decrements each iterator in ``m_iterator_tuple``.
146:Returns: ``*this``
147
148::
149
150 template<typename IteratorTuple>
151 zip_iterator<IteratorTuple>
152 make_zip_iterator(IteratorTuple t);
153
154:Returns: An instance of ``zip_iterator<IteratorTuple>`` with ``m_iterator_tuple``
155 initialized to ``t``.