diff --git a/rand/xoshiro.cpp b/rand/xoshiro.cpp index de35a65f..204324d7 100644 --- a/rand/xoshiro.cpp +++ b/rand/xoshiro.cpp @@ -36,6 +36,24 @@ xoshiro256plusplus::xoshiro256plusplus (u64 _seed) } +//----------------------------------------------------------------------------- +xoshiro256plusplus::xoshiro256plusplus (std::seed_seq &seq) +{ + std::generate ( + std::begin (m_state), + std::end (m_state), + [&] (void) { + u64 parts[2]; + seq.generate ( + std::begin (parts), + std::end (parts) + ); + return parts[0] << 4 | parts[1]; + } + ); +} + + /////////////////////////////////////////////////////////////////////////////// u64 xoshiro256plusplus::operator() (void) diff --git a/rand/xoshiro.hpp b/rand/xoshiro.hpp index 1344c057..204e1548 100644 --- a/rand/xoshiro.hpp +++ b/rand/xoshiro.hpp @@ -20,6 +20,7 @@ #include "../std.hpp" #include +#include /////////////////////////////////////////////////////////////////////////////// @@ -29,6 +30,7 @@ namespace cruft::rand { using result_type = u64; xoshiro256plusplus (u64 seed); + xoshiro256plusplus (std::seed_seq&); static constexpr result_type min (void) {