diff --git a/common/random.h b/common/random.h index 514c483e1..44be53e98 100644 --- a/common/random.h +++ b/common/random.h @@ -21,6 +21,9 @@ #include #include +#include +#include +#include /* This uses mt19937 seeded with the std::random_device * The idea is to have this be included as a member of another class @@ -62,6 +65,16 @@ namespace EQEmu { return Real(0.0, 1.0) <= required; } + // std::shuffle requires a RNG engine passed to it, so lets provide a wrapper to use our engine + template + void Shuffle(RandomAccessIterator first, RandomAccessIterator last) + { + static_assert(std::is_same::iterator_category>::value, + "EQEmu::Random::Shuffle requires random access iterators"); + std::shuffle(first, last, m_gen); + } + void Reseed() { // We could do the seed_seq thing here too if we need better seeding