Switch away from things that are removed in C++17
authorChristopher Dykes <cdykes@fb.com>
Thu, 14 Jul 2016 18:08:40 +0000 (11:08 -0700)
committerFacebook Github Bot <facebook-github-bot-bot@fb.com>
Thu, 14 Jul 2016 18:09:10 +0000 (11:09 -0700)
Summary:
That currently includes `std::binary_function`, `std::unary_function`, and `std::random_shuffle`.
`std::{unary|binary}_function<T{, T2}, Ret>` changes to `std::function<Ret(T{, T2})>`.
`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
folly/test/ConcurrentSkipListBenchmark.cpp
folly/test/sorted_vector_test.cpp

index df826299bf77929f4c28031a83d5cf0c879ba578..18540185a064ea5c19513bde5c9f26c986eddb89 100644 (file)
 #include <algorithm>
 #include <initializer_list>
 #include <iterator>
+#include <stdexcept>
+#include <type_traits>
 #include <utility>
 #include <vector>
+
 #include <boost/operators.hpp>
-#include <boost/bind.hpp>
-#include <boost/type_traits/is_same.hpp>
 
 namespace folly {
 
@@ -105,7 +106,7 @@ namespace detail {
   template<class Iterator>
   int distance_if_multipass(Iterator first, Iterator last) {
     typedef typename std::iterator_traits<Iterator>::iterator_category categ;
-    if (boost::is_same<categ,std::input_iterator_tag>::value)
+    if (std::is_same<categ,std::input_iterator_tag>::value)
       return -1;
     return std::distance(first, last);
   }
@@ -419,10 +420,7 @@ public:
   typedef std::pair<key_type,mapped_type>           value_type;
   typedef Compare                                   key_compare;
 
-  struct value_compare
-    : std::binary_function<value_type,value_type,bool>
-    , 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);
     }
index d1884a4a5795e0c954c50e4227637dc3491fc2aa..a41017f4b861f351f76bd9bc286ebac0b846c4b1 100644 (file)
@@ -17,6 +17,7 @@
 // @author: Xin Liu <xliux@fb.com>
 
 #include <map>
+#include <random>
 #include <set>
 #include <thread>
 
@@ -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() {
index d257a4ea4c233c46a9f499fae567db69a539865c..19a520347c3aad9597d938db5be1d48be2be5e38 100644 (file)
 #include <folly/sorted_vector_types.h>
 #include <gtest/gtest.h>
 #include <list>
+#include <memory>
 
 using folly::sorted_vector_set;
 using folly::sorted_vector_map;
 
 namespace {
 
-template<class T>
-struct less_invert : std::binary_function<T,T,bool> {
+template <class T>
+struct less_invert {
   bool operator()(const T& a, const T& b) const {
     return b < a;
   }