mardi 24 avril 2018

How does the 'uniform_int_distribution' random function works?

While looking for a way to generate a random integer, I stumbled upon these lines of code :

    std::random_device rd; 
    std::mt19937 generator(rd());
    std::uniform_int_distribution<> distribution(a, b);
    return distribution(generator);

What are the random_device and mt19937 types ? Why do you need these ? Whathappens precisely when you execute this kind of code with 2 integers a and b ?

Aucun commentaire:

Enregistrer un commentaire