Skip to content

Instantly share code, notes, and snippets.

@fabiogaluppo
Created November 5, 2015 23:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fabiogaluppo/64eb9045e9ab5621cb07 to your computer and use it in GitHub Desktop.
Save fabiogaluppo/64eb9045e9ab5621cb07 to your computer and use it in GitHub Desktop.
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