|
36 | 36 | #include <boost/algorithm/string/replace.hpp> |
37 | 37 | #include <boost/thread.hpp> |
38 | 38 |
|
| 39 | +#include <algorithm> |
| 40 | +// ================================================================ |
| 41 | +// C++17 compatibility: std::random_shuffle was removed. |
| 42 | +// We provide a replacement that preserves the old behavior. |
| 43 | +// ================================================================ |
| 44 | +template <typename RandomIt> |
| 45 | +static void RandomShuffleCompat(RandomIt first, RandomIt last) |
| 46 | +{ |
| 47 | +#if __cplusplus >= 201703L |
| 48 | + // Manual shuffle using GetRandInt() |
| 49 | + if (first == last) return; |
| 50 | + auto n = last - first; |
| 51 | + for (decltype(n) i = n - 1; i > 0; --i) { |
| 52 | + std::swap(first[i], first[GetRandInt(i + 1)]); |
| 53 | + } |
| 54 | +#else |
| 55 | + // Old compilers still have std::random_shuffle |
| 56 | + std::random_shuffle(first, last, GetRandInt); |
| 57 | +#endif |
| 58 | +} |
| 59 | + |
| 60 | + |
39 | 61 | std::vector<CWalletRef> vpwallets; |
40 | 62 | /** Transaction fee set by the user */ |
41 | 63 | CFeeRate payTxFee(DEFAULT_TRANSACTION_FEE); |
@@ -2392,7 +2414,7 @@ bool CWallet::SelectCoinsMinConf(const CAmount& nTargetValue, const int nConfMin |
2392 | 2414 | std::vector<CInputCoin> vValue; |
2393 | 2415 | CAmount nTotalLower = 0; |
2394 | 2416 |
|
2395 | | - random_shuffle(vCoins.begin(), vCoins.end(), GetRandInt); |
| 2417 | + RandomShuffleCompat(vCoins.begin(), vCoins.end()); |
2396 | 2418 |
|
2397 | 2419 | for (const COutput &output : vCoins) |
2398 | 2420 | { |
|
0 commit comments