How to do it...

To generate pseudo-random numbers in your application, you should perform the following steps:

  1. Include the header <random>:
        #include <random>
  1. Use anĀ std::random_device generator for seeding a pseudo-random engine:
        std::random_device rd{};
  1. Use one of the available engines for generating numbers and initialize it with a random seed:
        auto mtgen = std::mt19937{ rd() };
  1. Use one of the available distributions for converting the output of the engine to one of the desired statistical distributions:
        auto ud = std::uniform_int_distribution<>{ 1, 6 };
  1. Generate the pseudo-random numbers:
        for(auto i = 0; i < 20; ++i) 
auto number = ud(mtgen);