Created
September 18, 2012 13:47
-
-
Save kazuki-ma/3743198 to your computer and use it in GitHub Desktop.
tetlist::random
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
#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