For example:
for (...)
{
... std::uniform_real_distribution<float>(min, max)(rng) ...
}
Intuitively it seems to me that the constructor can't need to do much besides store the two values, and there shouldn't be any state in the uniform_*_distribution instance. I haven't profiled it myself (I'm not at that kind of stage in the project yet), but I felt this question belonged out there :)
I am aware that this would be a bad idea for some distribution types - for example, std::normal_distribution
might generate its numbers in pairs, and the second number would be wasted each time.
I feel what I have is more readable than just accessing rng()
and doing the maths myself, but I'd be interested if there are any other ways to write this more straightforwardly.
Aucun commentaire:
Enregistrer un commentaire