mirror of
https://github.com/catchorg/Catch2.git
synced 2025-05-28 15:39:27 +00:00
Fixed compile error under VS2015 /c++:latest, caused by using random_shuffle
Now if we detect C++11 compiler, or MSVC in version corresponding to VS2015, we switch from using `std::random_shuffle` to `std::shuffle`. `std::random_shuffle` was officially deprecated in C++14, and removed in C++17. Also removed guarded inclusion of `<random>` header, as there was nothing in the header that used it.
This commit is contained in:
parent
b50572bbfd
commit
6991549457
2 changed files with 9 additions and 6 deletions
|
@ -19,9 +19,6 @@
|
|||
#include <iostream>
|
||||
#include <algorithm>
|
||||
|
||||
#ifdef CATCH_CPP14_OR_GREATER
|
||||
#include <random>
|
||||
#endif
|
||||
|
||||
namespace Catch {
|
||||
|
||||
|
@ -30,7 +27,7 @@ namespace Catch {
|
|||
|
||||
result_type operator()( result_type n ) const { return std::rand() % n; }
|
||||
|
||||
#ifdef CATCH_CPP14_OR_GREATER
|
||||
#ifdef CATCH_CONFIG_CPP11_SHUFFLE
|
||||
static constexpr result_type min() { return 0; }
|
||||
static constexpr result_type max() { return 1000000; }
|
||||
result_type operator()() const { return std::rand() % max(); }
|
||||
|
@ -38,7 +35,7 @@ namespace Catch {
|
|||
template<typename V>
|
||||
static void shuffle( V& vector ) {
|
||||
RandomNumberGenerator rng;
|
||||
#ifdef CATCH_CPP14_OR_GREATER
|
||||
#ifdef CATCH_CONFIG_CPP11_SHUFFLE
|
||||
std::shuffle( vector.begin(), vector.end(), rng );
|
||||
#else
|
||||
std::random_shuffle( vector.begin(), vector.end(), rng );
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue