Instantly share code, notes, and snippets.

Embed
What would you like to do?
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