From 8cd0a77218b6a2ed9734b2d678a262f5334a156c Mon Sep 17 00:00:00 2001 From: David Leal Date: Fri, 26 May 2023 18:14:39 +0000 Subject: [PATCH] fix: use `random_shuffle` `random_shuffle` was removed in C++17, however, we're using C++11 here, so there should be no harm. --- games/memory_game.cpp | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-) diff --git a/games/memory_game.cpp b/games/memory_game.cpp index 1a5a38746..690763a35 100644 --- a/games/memory_game.cpp +++ b/games/memory_game.cpp @@ -10,7 +10,7 @@ * biggest table size and hardest mode. The bigger the size, **the more letters are available**. * * @author [David Leal](https://github.com/Panquesito7) -*/ + */ #include /// for IO operations #include /// for std::time() @@ -25,19 +25,6 @@ #include /// for sleep #endif -// `std::random_shuffle` was deprecated in C++14. To keep support with most compilers, we need to check the C++ version. -#if __cplusplus >= 201402L - template - constexpr auto SHUFFLE(T a, T b) -> void { - return std::shuffle(a, b, std::mt19937(std::random_device()())); - } -#else - template - constexpr auto SHUFFLE(T a, T b) -> void { - return std::random_shuffle(a, b); - } -#endif - /** * @namespace * @brief (Mini)game implementations. @@ -95,7 +82,7 @@ void init(std::vector *table) { pairs.push_back(letter); } - SHUFFLE(pairs.begin(), pairs.end()); + std::random_shuffle(pairs.begin(), pairs.end()); for (int i = 0; i < (*table).size(); i++) { (*table)[i] = pairs[i];