Browse Source

YT-22431: add patch to thrift for C++-17 compatibility
6cc1faf90b8b7c009e9df27e7e3c657b56698771

ignat 7 months ago
parent
commit
1f8ff429f5
1 changed files with 10 additions and 2 deletions
  1. 10 2
      contrib/restricted/thrift/thrift/transport/TSocketPool.cpp

+ 10 - 2
contrib/restricted/thrift/thrift/transport/TSocketPool.cpp

@@ -21,11 +21,13 @@
 
 #include <algorithm>
 #include <iostream>
+#if __cplusplus >= 201703L
+#include <random>
+#endif
 
 #include <thrift/transport/TSocketPool.h>
 
 using std::pair;
-using std::random_shuffle;
 using std::string;
 using std::vector;
 
@@ -189,7 +191,13 @@ void TSocketPool::open() {
   }
 
   if (randomize_ && numServers > 1) {
-    random_shuffle(servers_.begin(), servers_.end());
+#if __cplusplus >= 201703L
+    std::random_device rng;
+    std::mt19937 urng(rng());
+    std::shuffle(servers_.begin(), servers_.end(), urng);
+#else
+    std::random_shuffle(servers_.begin(), servers_.end());
+#endif
   }
 
   for (size_t i = 0; i < numServers; ++i) {