Skip to content

Instantly share code, notes, and snippets.

@kazuki-ma
Created September 18, 2012 13:47
Show Gist options
  • Save kazuki-ma/3743198 to your computer and use it in GitHub Desktop.
Save kazuki-ma/3743198 to your computer and use it in GitHub Desktop.
tetlist::random
#include <stdint.h>
#include <random>
namespace tetlist{
template <typename IntType>
class random{
#if defined(_WIN64) || defined(__LP64__)
typedef std::mt19937_64 mt19937;
#else
typedef std::mt19937 mt19937;
#endif
mt19937 generator;
std::uniform_int_distribution<IntType> distribution;
public:
random (const IntType min, const IntType max)
: generator(std::random_device())
, distribution(min, max)
{
}
IntType operator()() {
return distribution(generator);
}
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment