How to do it...

In this section, we will write a program that can print any tuple on the fly. In addition to that, we will write a function that can zip tuples together:

  1. We need to include a number of headers first and then we declare that we use the std namespace by default:
      #include <iostream>      #include <tuple>      #include <list>      #include <utility>      #include <string>      #include <iterator>      #include <numeric>      #include <algorithm>            using namespace std;

 

  1. As we will be dealing with tuples, it will be interesting to display their content. Therefore, we will now implement a very generic function that can print any tuple that consists of printable types. The function accepts an output stream reference os, which will be used to do the actual printing, ...

Get C++17 STL Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.