| Home | Libraries | People | FAQ | More

##### zip

###### Description

Zips sequences together to form a single sequence, whos members are tuples of the members of the component sequences.

###### Synopsis

    template<
        typename Sequence1,
        typename Sequence2,
        ...
        typename SequenceN
        >
    typename result_of::zip<Sequence1, Sequence2, ... SequenceN>::type
    zip(Sequence1 const& seq1, Sequence2 const& seq2, ... SequenceN const& seqN);

Table 1.68. Parameters

Parameter | Requirement | Description
--- | --- | ---
`seq1` to `seqN` | Each sequence is a model of Forward Sequence. | Operation's argument

###### Expression Semantics

    zip(seq1, seq2, ... seqN);

Return type: A model of Forward Sequence.

Semantics: Returns a sequence containing tuples of elements from sequences `seq1` to `seqN`. For example, applying zip to tuples `(1, 2, 3)` and `('a', 'b', 'c')` would return `((1, 'a'),(2, 'b'),(3, 'c'))`

###### Complexity

Constant. Returns a view which is lazily evaluated.

###### Header

    #include <boost/fusion/algorithm/transformation/zip.hpp>
    #include <boost/fusion/include/zip.hpp>

###### Example

    vector<int,char> v1(1, 'a');
    vector<int,char> v2(2, 'b');
    assert(zip(v1, v2) == make_vector(make_vector(1, 2),make_vector('a', 'b'));