#include <array> #include <bit> #include <random> #include <regex> namespace s2ga { template<class... T> struct always_false: std::false_type { }; class lehmer64 { public: lehmer64(__uint128_t seed = 0) { this->seed(seed); } void seed(__uint128_t z) { if(z == 0) { z = 0xC0FFEE; } s = z; } uint64_t operator()() noexcept { s *= 0xda942042e4dd58b5; return s >> 64; } static constexpr uint64_t min() { return 0; } static constexpr uint64_t max() { return UINT64_MAX; } template<typename T> T random(T min, T max) { if constexpr(std::is_integral_v<T>) { return std::uniform_int_distribution<T>(min, max)(*this); } else if constexpr(std::is_floating_point_v<T>) { return std::uniform_real_distribution<T>(min, max)(*this); } else { static_assert(always_false<T>::value, "unsupported distribution type"); } } private: __uint128_t s; }; static_assert(std::uniform_random_bit_generator<lehmer64>); }; // namespace s2ga inline void foo() { }