I see that std::shuffle takes an URNG argument.
I am using a custom version of a generator (WELL512a) and would like to use it with std::shuffle.
My question is : Is it possible to use it with std::shuffle?
For example maybe by using URNG as a base class?
We can see from the cppreference documentation on std::shuffle that:
URNG must meet the requirements of UniformRandomNumberGenerator.
unfortunately the site does not document what those requirements are, so we need to go to the draft C++11 standard section 26.5.1.3 Uniform random number generator requirements which says the following:
A uniform random number generator g of type G is a function object returning unsigned integer values such that each value in the range of possible results has (ideally) equal probability of being returned
A class G satisfies the requirements of a uniform random number generator if the expressions shown in Table 116 are valid and have the indicated semantics, and if G also satisfies all other requirements of this section 26.5.1.3. In that Table and throughout this section:
- T is the type named by G’s associated result_type, and
- g is a value of
Table 116 is summarized as follows:
The following relation shall hold: G::min() < G::max().
Update
To clarify when it says T is an unsigned integer type it means one of the following types covered in section 3.9.1 Fundamental types which include:
This also include extended unsigned integer types such as uinit64_t, if your platform supports them.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With