xso::generator — Generation

We have core methods that advance the generator’s state and reduce it to a single output word.

1constexpr result_type operator()();
2constexpr void        step();
1
Reduces the state to a single output word and calls step() to prepare for the next call.
This operator is required by the std::uniform_random_bit_generator concept.
2
This sub-operation of the operator()() method advances the state by one step without producing any output.
For the most part, users will rely on operator()(), which callsstep`, as part of its process.

Example: Run a randomly seeded generator for several trials

#include <xoshiro.h>
int main()
{
1    xso::rng gen;
    for (std::size_t i = 0; i < 10; ++i)
        std::cout << "Call " << i << ": gen() = " << gen() << '\n';
}
1
Create a randomly seeded generator.
Note that xso::rng is a type alias for xso::rng64 so gen will produce 64-bit outputs.

Output: The specific outputs will vary from run to run

Call 0: gen() = 6263138263434847173
Call 1: gen() = 8362716980094561668
Call 2: gen() = 11879325620643989793
Call 3: gen() = 6043654542199795453
Call 4: gen() = 5797233119354578927
Call 5: gen() = 2824358181435278861
Call 6: gen() = 16684351809006121981
Call 7: gen() = 14574163322765470879
Call 8: gen() = 3664863240348818305
Call 9: gen() = 3538750318106202103

See Also

discard
jump

Back to top