From: Willem Jan Withagen Date: Fri, 10 Aug 2018 11:58:54 +0000 (+0200) Subject: osd: make random shuffle comply with C++17 X-Git-Tag: v14.0.1~580^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=57f7a9f0058f123b6879ab1f4fd4096672e31a9c;p=ceph.git osd: make random shuffle comply with C++17 random_shuffle is depriacted in C++14 and removed in C++17 on FreeBSD (As per the standard) So this code does not compile on FreeBSD with Clang 6 Signed-off-by: Willem Jan Withagen --- diff --git a/src/osd/OSDMap.cc b/src/osd/OSDMap.cc index 2fa444351f72..59cbcc78e945 100644 --- a/src/osd/OSDMap.cc +++ b/src/osd/OSDMap.cc @@ -19,6 +19,7 @@ #include "OSDMap.h" #include +#include #include "common/config.h" #include "common/errno.h" #include "common/Formatter.h" @@ -5198,7 +5199,9 @@ void OSDMap::get_random_up_osds_by_subtree(int n, // whoami return; vector subtrees; crush->get_subtree_of_type(subtree_type, &subtrees); - std::random_shuffle(subtrees.begin(), subtrees.end()); + std::random_device rd; + std::default_random_engine rng{rd()}; + std::shuffle(subtrees.begin(), subtrees.end(), rng); for (auto s : subtrees) { if (limit <= 0) break;