#include #include #include #include namespace s2ga { template 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 T random(T min, T max) { if constexpr(std::is_integral_v) { return std::uniform_int_distribution(min, max)(*this); } else if constexpr(std::is_floating_point_v) { return std::uniform_real_distribution(min, max)(*this); } else { static_assert(always_false::value, "unsupported distribution type"); } } private: __uint128_t s; }; static_assert(std::uniform_random_bit_generator); }; // namespace s2ga inline void foo() { }