update random.hpp

This commit is contained in:
MihailRis 2025-09-16 19:12:25 +03:00
parent eb760e1776
commit dc21a8ea51

View File

@ -5,10 +5,10 @@
#include <algorithm>
namespace util {
template <class T = std::mt19937, std::size_t N = T::state_size * sizeof(typename T::result_type)>
typename std::enable_if<N, T>::type seeded_random_engine(
std::random_device& source
) {
template <
class T = std::mt19937,
std::size_t N = T::state_size * sizeof(typename T::result_type)>
auto seeded_random_engine(std::random_device& source) {
std::random_device::result_type randomData[(N - 1) / sizeof(source()) + 1];
std::generate(std::begin(randomData), std::end(randomData), std::ref(source));
std::seed_seq seeds(std::begin(randomData), std::end(randomData));