From 048c596476a712233b4e63e276b4fc41a85bf04f Mon Sep 17 00:00:00 2001 From: Christopher Dykes Date: Thu, 14 Jul 2016 11:08:40 -0700 Subject: [PATCH] Switch away from things that are removed in C++17 Summary: That currently includes `std::binary_function`, `std::unary_function`, and `std::random_shuffle`. `std::{unary|binary}_function` changes to `std::function`. `std::random_shuffle` has no immediate equivalent, but `std::shuffle` while passing a specific RNG achieves the same effect. Reviewed By: yfeldblum Differential Revision: D3506405 fbshipit-source-id: cdefc698a841eca762174eddd8ce636e2d8d26ef --- folly/sorted_vector_types.h | 12 +++++------- folly/test/ConcurrentSkipListBenchmark.cpp | 9 +++++---- folly/test/sorted_vector_test.cpp | 5 +++-- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/folly/sorted_vector_types.h b/folly/sorted_vector_types.h index df826299..18540185 100644 --- a/folly/sorted_vector_types.h +++ b/folly/sorted_vector_types.h @@ -62,11 +62,12 @@ #include #include #include +#include +#include #include #include + #include -#include -#include namespace folly { @@ -105,7 +106,7 @@ namespace detail { template int distance_if_multipass(Iterator first, Iterator last) { typedef typename std::iterator_traits::iterator_category categ; - if (boost::is_same::value) + if (std::is_same::value) return -1; return std::distance(first, last); } @@ -419,10 +420,7 @@ public: typedef std::pair value_type; typedef Compare key_compare; - struct value_compare - : std::binary_function - , private Compare - { + struct value_compare : private Compare { bool operator()(const value_type& a, const value_type& b) const { return Compare::operator()(a.first, b.first); } diff --git a/folly/test/ConcurrentSkipListBenchmark.cpp b/folly/test/ConcurrentSkipListBenchmark.cpp index d1884a4a..a41017f4 100644 --- a/folly/test/ConcurrentSkipListBenchmark.cpp +++ b/folly/test/ConcurrentSkipListBenchmark.cpp @@ -17,6 +17,7 @@ // @author: Xin Liu #include +#include #include #include @@ -53,7 +54,7 @@ static void initData() { for (int i = 0; i < kMaxValue; ++i) { gData[i] = i; } - std::random_shuffle(gData.begin(), gData.end()); + std::shuffle(gData.begin(), gData.end(), std::mt19937{}); } // single thread benchmarks @@ -374,9 +375,9 @@ class ConcurrentAccessData { // half new values and half already in the list writeValues_.push_back((rand() % 2) + 2 * i); } - std::random_shuffle(readValues_.begin(), readValues_.end()); - std::random_shuffle(deleteValues_.begin(), deleteValues_.end()); - std::random_shuffle(writeValues_.begin(), writeValues_.end()); + std::shuffle(readValues_.begin(), readValues_.end(), std::mt19937{}); + std::shuffle(deleteValues_.begin(), deleteValues_.end(), std::mt19937{}); + std::shuffle(writeValues_.begin(), writeValues_.end(), std::mt19937{}); } ~ConcurrentAccessData() { diff --git a/folly/test/sorted_vector_test.cpp b/folly/test/sorted_vector_test.cpp index d257a4ea..19a52034 100644 --- a/folly/test/sorted_vector_test.cpp +++ b/folly/test/sorted_vector_test.cpp @@ -17,14 +17,15 @@ #include #include #include +#include using folly::sorted_vector_set; using folly::sorted_vector_map; namespace { -template -struct less_invert : std::binary_function { +template +struct less_invert { bool operator()(const T& a, const T& b) const { return b < a; } -- 2.34.1