How to do it...

We will implement a procedure that prints a nice illustrating histogram of the numbers a random generator produces. Then, we will run all STL random number generator engines through this procedure and learn from the results. This program contains many repetitive lines, so it might be advantageous to just copy the source code from the code repository accompanying this book on the Internet instead of typing all the repetitive code manually.

  1. At first, we include all the necessary headers and then declare that we use the std namespace by default:
      #include <iostream>      #include <string>      #include <vector>      #include <random>      #include <iomanip>      #include <limits>      #include <cstdlib>      #include <algorithm>            using namespace std;
  1. Then ...

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.