...one of the most highly
regarded and expertly designed C++ library projects in the
world.
— Herb Sutter and Andrei
Alexandrescu, C++
Coding Standards
Zips sequences together to form a single sequence, whos members are tuples of the members of the component sequences.
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 |
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'))
Constant. Returns a view which is lazily evaluated.
#include <boost/fusion/algorithm/transformation/zip.hpp> #include <boost/fusion/include/zip.hpp>
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'));