example1_basic_usage.cpp

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
#include <iostream>
#include <random>

int main() {
    std::random_device rd;

    // Generate and print a few random numbers
    for (int i = 0; i < 5; ++i) {
        std::cout << "Random number: " << rd() << std::endl;
    }

    // Print the range of generated numbers
    std::cout << "Min value: " << rd.min() << std::endl;
    std::cout << "Max value: " << rd.max() << std::endl;

    return 0;
}
Back to std_random_device