rand/xoshiro: add a std::seed_seq constructor
This commit is contained in:
parent
3d5258b974
commit
5f4c95aa11
@ -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)
|
||||
|
@ -20,6 +20,7 @@
|
||||
#include "../std.hpp"
|
||||
|
||||
#include <limits>
|
||||
#include <random>
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
@ -29,6 +30,7 @@ namespace cruft::rand {
|
||||
using result_type = u64;
|
||||
|
||||
xoshiro256plusplus (u64 seed);
|
||||
xoshiro256plusplus (std::seed_seq&);
|
||||
|
||||
static constexpr result_type min (void)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user