Replaced use of std::rand with std::mt19937

This uses a global instance of the RNG
This commit is contained in:
Phil Nash
2018-06-15 14:35:47 +01:00
parent 1dce91d78e
commit 35a57b070f
3 changed files with 14 additions and 31 deletions

View File

@@ -8,31 +8,16 @@
#define TWOBLUECUBES_CATCH_RANDOM_NUMBER_GENERATOR_H_INCLUDED
#include <algorithm>
#include <random>
namespace Catch {
struct IConfig;
std::mt19937& rng();
void seedRng( IConfig const& config );
unsigned int rngSeed();
struct RandomNumberGenerator {
using result_type = unsigned int;
static constexpr result_type (min)() { return 0; }
static constexpr result_type (max)() { return 1000000; }
result_type operator()( result_type n ) const;
result_type operator()() const;
template<typename V>
static void shuffle( V& vector ) {
RandomNumberGenerator rng;
std::shuffle( vector.begin(), vector.end(), rng );
}
};
}
#endif // TWOBLUECUBES_CATCH_RANDOM_NUMBER_GENERATOR_H_INCLUDED