Created
October 9, 2020 06:09
-
-
Save tanzby/beed526709560cb7b97ffcfb3108a786 to your computer and use it in GitHub Desktop.
Generate Uniform Random Value
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <random> | |
| template <typename T> | |
| int UniformRand(const T min, const T max) | |
| { | |
| static thread_local std::mt19937 generator(std::random_device{}()); | |
| std::uniform_int_distribution<T> distribution(min, max); | |
| return distribution(generator); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment