// the 'std' namespace; the latter uses inline namepsaces. Wrap this decision
// up in a macro to make forward-declarations easier.
#if FOLLY_USE_LIBCPP
+#include <__config>
#define FOLLY_NAMESPACE_STD_BEGIN _LIBCPP_BEGIN_NAMESPACE_STD
#define FOLLY_NAMESPACE_STD_END _LIBCPP_END_NAMESPACE_STD
#else
StateSize<std::subtract_with_carry_engine<UIntType, w, s, r>>::value;
template <class RNG>
-std::seed_seq generateSeed() {
- std::array<uint32_t, StateSize<RNG>::value> seed_data;
- Random::secureRandom(seed_data.begin(), seed_data.size() * sizeof(uint32_t));
- return std::seed_seq(std::begin(seed_data), std::end(seed_data));
-}
+struct SeedData {
+ SeedData() {
+ Random::secureRandom(seedData.begin(), seedData.size() * sizeof(uint32_t));
+ }
+
+ static constexpr size_t stateSize = StateSize<RNG>::value;
+ std::array<uint32_t, stateSize> seedData;
+};
} // namespace detail
template <class RNG>
void Random::seed(ValidRNG<RNG>& rng) {
- auto s = detail::generateSeed<RNG>();
+ detail::SeedData<RNG> sd;
+ std::seed_seq s(std::begin(sd.seedData), std::end(sd.seedData));
rng.seed(s);
}
template <class RNG>
auto Random::create() -> ValidRNG<RNG> {
- auto s = detail::generateSeed<RNG>();
+ detail::SeedData<RNG> sd;
+ std::seed_seq s(std::begin(sd.seedData), std::end(sd.seedData));
return RNG(s);
}