
Integer division is slow - ingve
https://kristerw.blogspot.com/2017/05/integer-division-is-slow.html
======
Veedrac
Your code

    
    
        std::random_device entropySource;
        std::mt19937 randGenerator(entropySource());
    

does not properly seed a mt19937. To copy a comment I made just two weeks ago
(this error is a direct result of <random>'s poor design),

It is unfortunate how people keep trying to use `std::mt19937` and,
unsurprisingly given how hard it is to use, how they (almost)[0] inevitably
fail. Do yourself a favour and use a randomness library that doesn't hate
you[1], is simple to seed correctly[2], produces decent quality randomness[3],
isn't horribly bloated[4] and has more features[5] to boot. It's 2017. Let the
Mersenne Twister die.

[0]:
[https://codereview.stackexchange.com/q/114066/40768](https://codereview.stackexchange.com/q/114066/40768)

[1]: [http://www.pcg-random.org/](http://www.pcg-random.org/)

[2]: [http://www.pcg-random.org/posts/cpps-random_device.html](http://www.pcg-
random.org/posts/cpps-random_device.html)

[3]: [http://www.pcg-random.org/paper.html](http://www.pcg-
random.org/paper.html)

[4]:
[https://cs.stackexchange.com/q/50059/16408](https://cs.stackexchange.com/q/50059/16408)

[5]: [http://www.pcg-random.org/using-pcg-cpp.html#extra-
features](http://www.pcg-random.org/using-pcg-cpp.html#extra-features)

------
DarkKomunalec
How come the optimizer doesn't figure out theIntDist is constant if it's
declared outside the loop? Given that the function is templated, it should
have access to its internals, and so have all the information needed to do
constant propagation, no?

