Closed martinus closed 1 year ago
This might work:
template <typename Container> void Rng::shuffle(Container& container) noexcept { auto size = static_cast<uint32_t>(container.size()); auto i = size; while (i > 2U) { using std::swap; auto n = operator()(); auto b1 = (static_cast<uint32_t>(n) * static_cast<uint64_t>(i)) >> 32U; swap(container[--i], container[b1]); auto b2 = ((n >> 32U) * i) >> 32U; swap(container[--i], container[b2]); } }
released in 4.3.8
This might work: