mirror of
https://github.com/Xahau/xahaud.git
synced 2025-12-06 17:27:52 +00:00
MSVC std::sample workaround
This commit is contained in:
@@ -1273,14 +1273,25 @@ struct PeerDataCounts
|
|||||||
if (counts.empty())
|
if (counts.empty())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
auto outFunc = [&f](auto&& v) { f(v.first); };
|
||||||
std::minstd_rand rng{std::random_device{}()};
|
std::minstd_rand rng{std::random_device{}()};
|
||||||
|
#if _MSC_VER
|
||||||
|
std::vector<std::pair<std::shared_ptr<Peer>, 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(
|
std::sample(
|
||||||
counts.begin(),
|
counts.begin(),
|
||||||
counts.end(),
|
counts.end(),
|
||||||
boost::make_function_output_iterator(
|
boost::make_function_output_iterator(outFunc),
|
||||||
[&f](auto&& v) { f(v.first); }),
|
|
||||||
n,
|
n,
|
||||||
rng);
|
rng);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
} // namespace detail
|
} // namespace detail
|
||||||
|
|||||||
Reference in New Issue
Block a user