...

/

Build a Zip Iterator Adapter

Build a Zip Iterator Adapter

Learn to build a zip iterator adapter.

We'll cover the following...

Many scripting languagesScripting languages are programming languages used for rapid application development and automation, typically interpreted rather than compiled. include a function for zipping two sequences together. A typical zip operation will take two input sequences and return a pair of values for each position in both inputs:

Let's consider the scenario of two sequences—they can be containers, iterators, or initialization lists.

Press + to interact
Containers to be zipped
Containers to be zipped

We want to zip them together to make a new sequence with pairs of elements from the first two sequences:

Press + to interact
Zip operation
Zip operation

In this recipe we will accomplish this task with an iterator adapter.

How to do it

In this recipe we’ll build a zip iterator adapter that takes two containers of the same type and zips the values into std::pair objects:

  • In our main() function we ...