37 using result_type = std::random_device::result_type;
38 using pseudo_engine = std::mt19937_64;
46 sizeof(result_type) == 2 ||
47 sizeof(result_type) == 4 ||
48 sizeof(result_type) == 8,
49 "result_type must be 16, 32 or 64 bits");
53 result_type operator()();
55 static constexpr result_type min() {
56 return std::numeric_limits<result_type>::lowest();
59 static constexpr result_type max() {
60 return std::numeric_limits<result_type>::max();
63 double entropy()
const {
64 if (hasRdrand() or hasRdseed())
69 static bool hasRdrand() {
70 static const bool hasrdrand = _hasRdrand();
74 static bool hasRdseed() {
75 static const bool hasrdseed = _hasRdseed();
80 random_device& operator=(random_device&) =
delete;
83 std::uniform_int_distribution<result_type> dis {};
85 static bool hasIntelCpu();
86 static bool _hasRdrand();
87 static bool _hasRdseed();
94 CPUIDinfo(
const unsigned int func,
const unsigned int subfunc);
96 bool rdrandStep(result_type* r);
97 bool rdrand(result_type* r);
98 bool rdseedStep(result_type* r);
99 bool rdseed(result_type* r);
104 using random_device = std::random_device;
108 using random_device = std::random_device;
111 template<
class T = std::mt19937, std::
size_t N = T::state_size>
112 auto getSeededRandomEngine () ->
typename std::enable_if<!!N, T>::type {
113 typename T::result_type random_data[N];
114 random_device source;
115 std::generate(std::begin(random_data), std::end(random_data), std::ref(source));
116 std::seed_seq seeds(std::begin(random_data), std::end(random_data));
117 T seededEngine (seeds);