diff --git a/include/pcglite/pcglite.hpp b/include/pcglite/pcglite.hpp index 3cce238..9f48d73 100644 --- a/include/pcglite/pcglite.hpp +++ b/include/pcglite/pcglite.hpp @@ -28,7 +28,6 @@ #ifndef PCGLITE_PCGLITE_HPP_ #define PCGLITE_PCGLITE_HPP_ -#include #include #include #include @@ -71,8 +70,15 @@ template <> inline constexpr __uint128_t default_increment<__uint128_t> template <> inline constexpr __uint128_t default_state<__uint128_t> = constexpr_uint128(0xb8dc10e158a92392ULL, 0x98046df007ec0a53ULL); +template +union SeedSeqData { + state_type as_state_type[N]; + uint32_t as_uint32_t[N * sizeof(state_type) / sizeof(uint32_t)]; +}; + } // namespace detail + template class permuted_congruential_engine { public: @@ -106,9 +112,10 @@ class permuted_congruential_engine { template std::enable_if_t> seed(SeedSeq& q) { - std::array data; - q.generate(data.begin(), data.end()); - seed(data[0], data[1]); + detail::SeedSeqData data{}; + constexpr int len = sizeof(data.as_uint32_t) / sizeof(uint32_t); + q.generate(data.as_uint32_t, data.as_uint32_t + len); + seed(data.as_state_type[1], data.as_state_type[0]); } result_type operator()() noexcept { diff --git a/test/identical.cpp b/test/identical.cpp index bd4943d..55d232c 100644 --- a/test/identical.cpp +++ b/test/identical.cpp @@ -113,14 +113,12 @@ int main() { ret |= ctor2(); ret |= seed1(); ret |= seed2(); + ret |= seedseq(); ret |= ctor0_64(); ret |= ctor1_64(); ret |= ctor2_64(); ret |= seed1_64(); ret |= seed2_64(); - if (false) {// TODO - ret |= seedseq(); - ret |= seedseq_64(); - } + ret |= seedseq_64(); return ret; }