#pragma once #include "common.h" namespace rng { template struct seed_gen { virtual T generate_seed() = 0; inline virtual ~seed_gen(){} }; namespace seed { struct splitmix64 : public virtual seed_gen { inline splitmix64(const splitmix64&) = default; explicit inline splitmix64(seed_gen& from) : m_state(from.generate_seed()){} splitmix64(u64 i); u64 generate_seed() override; f64 generate_f64(); inline virtual ~splitmix64() override{} static u64 oneshot(u64& state); inline static u64 oneshot(const u64& state) { u64 s = state; return oneshot(s); } static f64 oneshotf(u64& state); inline static f64 oneshotf(const u64& state) { u64 s = state; return oneshotf(s); } static splitmix64 random(); private: u64 m_state; }; } }