O'Reilly logo

C++17 STL Cookbook by Jacek Galowicz

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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, ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required