diff --git a/src/ripple/app/ledger/impl/InboundLedger.cpp b/src/ripple/app/ledger/impl/InboundLedger.cpp index 6609759d0..d24c451a1 100644 --- a/src/ripple/app/ledger/impl/InboundLedger.cpp +++ b/src/ripple/app/ledger/impl/InboundLedger.cpp @@ -1273,14 +1273,25 @@ struct PeerDataCounts if (counts.empty()) return; + auto outFunc = [&f](auto&& v) { f(v.first); }; std::minstd_rand rng{std::random_device{}()}; +#if _MSC_VER + std::vector, int>> s; + s.reserve(n); + std::sample( + counts.begin(), counts.end(), std::back_inserter(s), n, rng); + for (auto& v : s) + { + outFunc(v); + } +#else std::sample( counts.begin(), counts.end(), - boost::make_function_output_iterator( - [&f](auto&& v) { f(v.first); }), + boost::make_function_output_iterator(outFunc), n, rng); +#endif } }; } // namespace detail