-
-
Save fabiogaluppo/64eb9045e9ab5621cb07 to your computer and use it in GitHub Desktop.
This file contains 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
template<typename T> struct iota_random_with_uniform_distribution final | |
{ | |
explicit iota_random_with_uniform_distribution(const T minInclusive, const T maxInclusive, unsigned int seed = 5489U) | |
: rnd(std::bind(std::uniform_int_distribution<T>(minInclusive, maxInclusive), std::default_random_engine(seed))) | |
{ | |
next = rnd(); | |
} | |
iota_random_with_uniform_distribution& operator++() | |
{ | |
next = rnd(); | |
return *this; | |
} | |
operator T() const { return next; } | |
private: | |
T next; | |
std::function<T(void)> rnd; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment