IteratorTuple m_iterator_tuple; // exposition only
};
template<typename IteratorTuple>
zip_iterator<IteratorTuple>
make_zip_iterator(IteratorTuple t);
</pre>
<p>The <ttclass="literal"><spanclass="pre">reference</span></tt> member of <ttclass="literal"><spanclass="pre">zip_iterator</span></tt> is the type of the tuple
made of the reference types of the iterator types in the <ttclass="literal"><spanclass="pre">IteratorTuple</span></tt>
argument.</p>
<p>The <ttclass="literal"><spanclass="pre">difference_type</span></tt> member of <ttclass="literal"><spanclass="pre">zip_iterator</span></tt> is the <ttclass="literal"><spanclass="pre">difference_type</span></tt>
of the first of the iterator types in the <ttclass="literal"><spanclass="pre">IteratorTuple</span></tt> argument.</p>
<p>The <ttclass="literal"><spanclass="pre">iterator_category</span></tt> member of <ttclass="literal"><spanclass="pre">zip_iterator</span></tt> is convertible to the
minimum of the traversal categories of the iterator types in the <ttclass="literal"><spanclass="pre">IteratorTuple</span></tt>
argument. For example, if the <ttclass="literal"><spanclass="pre">zip_iterator</span></tt> holds only vector
iterators, then <ttclass="literal"><spanclass="pre">iterator_category</span></tt> is convertible to
<ttclass="literal"><spanclass="pre">boost::random_access_traversal_tag</span></tt>. If you add a list iterator, then
<ttclass="literal"><spanclass="pre">iterator_category</span></tt> will be convertible to <ttclass="literal"><spanclass="pre">boost::bidirectional_traversal_tag</span></tt>,
but no longer to <ttclass="literal"><spanclass="pre">boost::random_access_traversal_tag</span></tt>.</p>
<p>The fact that the <ttclass="literal"><spanclass="pre">zip_iterator</span></tt> models only Readable Iterator does not
prevent you from modifying the values that the individual iterators point
to. The tuple returned by the <ttclass="literal"><spanclass="pre">zip_iterator</span></tt>'s <ttclass="literal"><spanclass="pre">operator*</span></tt> is a tuple
constructed from the reference types of the individual iterators, not
their value types. For example, if <ttclass="literal"><spanclass="pre">zip_it</span></tt> is a <ttclass="literal"><spanclass="pre">zip_iterator</span></tt> whose
first member iterator is an <ttclass="literal"><spanclass="pre">std::vector<double>::iterator</span></tt>, then the
following line will modify the value which the first member iterator of
<ttclass="literal"><spanclass="pre">zip_it</span></tt> currently points to:</p>
<preclass="literal-block">
zip_it->get<0>() = 42.0;
</pre>
<p>Consider the set of standard traversal concepts obtained by taking
the most refined standard traversal concept modeled by each individual
iterator type in the <ttclass="literal"><spanclass="pre">IteratorTuple</span></tt> argument.The <ttclass="literal"><spanclass="pre">zip_iterator</span></tt>
models the least refined standard traversal concept in this set.</p>
<p><ttclass="literal"><spanclass="pre">zip_iterator<IteratorTuple1></span></tt> is interoperable with
<ttclass="literal"><spanclass="pre">zip_iterator<IteratorTuple2></span></tt> if and only if <ttclass="literal"><spanclass="pre">IteratorTuple1</span></tt>
is interoperable with <ttclass="literal"><spanclass="pre">IteratorTuple2</span></tt>.</p>
<trclass="field"><thclass="field-name">Returns:</th><tdclass="field-body">An instance of <ttclass="literal"><spanclass="pre">zip_iterator</span></tt> with <ttclass="literal"><spanclass="pre">m_iterator_tuple</span></tt>
<trclass="field"><thclass="field-name">Returns:</th><tdclass="field-body">An instance of <ttclass="literal"><spanclass="pre">zip_iterator</span></tt> with <ttclass="literal"><spanclass="pre">m_iterator_tuple</span></tt>
initialized to <ttclass="literal"><spanclass="pre">iterator_tuple</span></tt>.</td>
</tr>
</tbody>
</table>
<preclass="literal-block">
template<typename OtherIteratorTuple>
zip_iterator(
const zip_iterator<OtherIteratorTuple>& other
, typename enable_if_convertible<
OtherIteratorTuple
, IteratorTuple>::type* = 0 // exposition only
);
</pre>
<tableclass="field-list"frame="void"rules="none">
<colclass="field-name"/>
<colclass="field-body"/>
<tbodyvalign="top">
<trclass="field"><thclass="field-name">Returns:</th><tdclass="field-body">An instance of <ttclass="literal"><spanclass="pre">zip_iterator</span></tt> that is a copy of <ttclass="literal"><spanclass="pre">other</span></tt>.</td>
</tr>
<trclass="field"><thclass="field-name">Requires:</th><tdclass="field-body"><ttclass="literal"><spanclass="pre">OtherIteratorTuple</span></tt> is implicitly convertible to <ttclass="literal"><spanclass="pre">IteratorTuple</span></tt>.</td>
<trclass="field"><thclass="field-name">Effects:</th><tdclass="field-body">Increments each iterator in <ttclass="literal"><spanclass="pre">m_iterator_tuple</span></tt>.</td>
<trclass="field"><thclass="field-name">Effects:</th><tdclass="field-body">Decrements each iterator in <ttclass="literal"><spanclass="pre">m_iterator_tuple</span></tt>.</td>
<trclass="field"><thclass="field-name">Returns:</th><tdclass="field-body">An instance of <ttclass="literal"><spanclass="pre">zip_iterator<IteratorTuple></span></tt> with <ttclass="literal"><spanclass="pre">m_iterator_tuple</span></tt>
initialized to <ttclass="literal"><spanclass="pre">t</span></tt>.</td>
</tr>
</tbody>
</table>
<preclass="literal-block">
template<typename IteratorTuple>
zip_iterator<IteratorTuple>
make_zip_iterator(IteratorTuple t);
</pre>
<tableclass="field-list"frame="void"rules="none">
<colclass="field-name"/>
<colclass="field-body"/>
<tbodyvalign="top">
<trclass="field"><thclass="field-name">Returns:</th><tdclass="field-body">An instance of <ttclass="literal"><spanclass="pre">zip_iterator<IteratorTuple></span></tt> with <ttclass="literal"><spanclass="pre">m_iterator_tuple</span></tt>
initialized to <ttclass="literal"><spanclass="pre">t</span></tt>.</td>
<p>The second important application of the <ttclass="literal"><spanclass="pre">zip_iterator</span></tt> is as a building block
to make combining iterators. A combining iterator is an iterator
that parallel-iterates over several controlled sequences and, upon
dereferencing, returns the result of applying a functor to the values of the
sequences at the respective positions. This can now be achieved by using the
<ttclass="literal"><spanclass="pre">zip_iterator</span></tt> in conjunction with the <ttclass="literal"><spanclass="pre">transform_iterator</span></tt>.</p>
<p>Suppose, for example, that you have two vectors of doubles, say
<ttclass="literal"><spanclass="pre">vect_1</span></tt> and <ttclass="literal"><spanclass="pre">vect_2</span></tt>, and you need to expose to a client
a controlled sequence containing the products of the elements of
<ttclass="literal"><spanclass="pre">vect_1</span></tt> and <ttclass="literal"><spanclass="pre">vect_2</span></tt>. Rather than placing these products
in a third vector, you can use a combining iterator that calculates the
products on the fly. Let us assume that <ttclass="literal"><spanclass="pre">tuple_multiplies</span></tt> is a
functor that works like <ttclass="literal"><spanclass="pre">std::multiplies</span></tt>, except that it takes
its two arguments packaged in a tuple. Then the two iterators
<ttclass="literal"><spanclass="pre">it_begin</span></tt> and <ttclass="literal"><spanclass="pre">it_end</span></tt> defined below delimit a controlled
sequence containing the products of the elements of <ttclass="literal"><spanclass="pre">vect_1</span></tt> and
Generated by <aclass="reference"href="http://docutils.sourceforge.net/">Docutils</a> from <aclass="reference"href="http://docutils.sourceforge.net/rst.html">reStructuredText</a> source.