Skip to content

Commit 8cd0a77

Browse files
committed
fix: use random_shuffle
`random_shuffle` was removed in C++17, however, we're using C++11 here, so there should be no harm.
1 parent 2202ea1 commit 8cd0a77

File tree

1 file changed

+2
-15
lines changed

1 file changed

+2
-15
lines changed

games/memory_game.cpp

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
* biggest table size and hardest mode. The bigger the size, **the more letters are available**.
1111
*
1212
* @author [David Leal](https://github.com/Panquesito7)
13-
*/
13+
*/
1414

1515
#include <iostream> /// for IO operations
1616
#include <ctime> /// for std::time()
@@ -25,19 +25,6 @@
2525
#include <unistd.h> /// for sleep
2626
#endif
2727

28-
// `std::random_shuffle` was deprecated in C++14. To keep support with most compilers, we need to check the C++ version.
29-
#if __cplusplus >= 201402L
30-
template <typename T>
31-
constexpr auto SHUFFLE(T a, T b) -> void {
32-
return std::shuffle(a, b, std::mt19937(std::random_device()()));
33-
}
34-
#else
35-
template <typename T>
36-
constexpr auto SHUFFLE(T a, T b) -> void {
37-
return std::random_shuffle(a, b);
38-
}
39-
#endif
40-
4128
/**
4229
* @namespace
4330
* @brief (Mini)game implementations.
@@ -95,7 +82,7 @@ void init(std::vector<T> *table) {
9582
pairs.push_back(letter);
9683
}
9784

98-
SHUFFLE(pairs.begin(), pairs.end());
85+
std::random_shuffle(pairs.begin(), pairs.end());
9986

10087
for (int i = 0; i < (*table).size(); i++) {
10188
(*table)[i] = pairs[i];

0 commit comments

Comments
 (0)