std::generate_n

cppreference.com

Example

main: () = {
    rng: std::mt19937 = (); // default constructed, seeded with fixed seed
    out_it:_ = std::ostream_iterator<std::mt19937::result_type>(std::cout, " ");
    std::generate_n(out_it, 5, std::ref(rng));
    std::cout << '\n';
    _ = rng;
}

Output

3499211612 581869302 3890346734 3586334585 545404204

Back to top

cpp2reference.com licensed under CC-BY-SA and GFDL.