I have a bunch of questions about random engines and distributions, their cost and interaction:
- Is std::random_device an expensive (heavy constructible) object? Should I only create one for my application if possible?
- Are RandomNumberDistribution objects are expensive objects or is it mostly dependent of concrete distribution? It seems to me that for example uniform_int_distribution should be very light object containing distribution range [min, max] and may be (?) some internal state.
-
How works interaction between random_device, random_engine and distribution in code below:
std::random_device rd; std::mt19937 gen(rd()); std::uniform_int_distribution<> distr(1, 10); auto random_value = distr(gen);what happens in last line? Distribution get next value from random engine and then brings it to desired range [0, 10]? Always obviously internal states of some objects should be modified after call: definitely random_device, random_engine but does uniform_int_distribution also have some internal state?
Aucun commentaire:
Enregistrer un commentaire