mirror of
https://github.com/catchorg/Catch2.git
synced 2024-12-23 19:53:28 +01:00
96c5de678d
`result_type` must be unsigned: http://en.cppreference.com/w/cpp/concept/UniformRandomBitGenerator Using a signed type causes an infinite loop working with MS Visual Studio 2017, targetting: v140, WindowsTargetPlatformVersion 10.0.15063.0, Debug, x64
41 lines
1.0 KiB
C++
41 lines
1.0 KiB
C++
/*
|
|
* Created by Martin on 30/08/2017.
|
|
*
|
|
* Distributed under the Boost Software License, Version 1.0. (See accompanying
|
|
* file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
|
*/
|
|
#ifndef TWOBLUECUBES_CATCH_RANDOM_NUMBER_GENERATOR_H_INCLUDED
|
|
#define TWOBLUECUBES_CATCH_RANDOM_NUMBER_GENERATOR_H_INCLUDED
|
|
|
|
#include "catch_random_number_generator.h"
|
|
|
|
#include <algorithm>
|
|
|
|
namespace Catch {
|
|
|
|
struct IConfig;
|
|
|
|
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
|