Commit 048c5964 authored by Christopher Dykes's avatar Christopher Dykes Committed by Facebook Github Bot

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<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
parent a5f4fbe0
...@@ -62,11 +62,12 @@ ...@@ -62,11 +62,12 @@
#include <algorithm> #include <algorithm>
#include <initializer_list> #include <initializer_list>
#include <iterator> #include <iterator>
#include <stdexcept>
#include <type_traits>
#include <utility> #include <utility>
#include <vector> #include <vector>
#include <boost/operators.hpp> #include <boost/operators.hpp>
#include <boost/bind.hpp>
#include <boost/type_traits/is_same.hpp>
namespace folly { namespace folly {
...@@ -105,7 +106,7 @@ namespace detail { ...@@ -105,7 +106,7 @@ namespace detail {
template<class Iterator> template<class Iterator>
int distance_if_multipass(Iterator first, Iterator last) { int distance_if_multipass(Iterator first, Iterator last) {
typedef typename std::iterator_traits<Iterator>::iterator_category categ; 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 -1;
return std::distance(first, last); return std::distance(first, last);
} }
...@@ -419,10 +420,7 @@ public: ...@@ -419,10 +420,7 @@ public:
typedef std::pair<key_type,mapped_type> value_type; typedef std::pair<key_type,mapped_type> value_type;
typedef Compare key_compare; typedef Compare key_compare;
struct value_compare struct value_compare : private Compare {
: std::binary_function<value_type,value_type,bool>
, private Compare
{
bool operator()(const value_type& a, const value_type& b) const { bool operator()(const value_type& a, const value_type& b) const {
return Compare::operator()(a.first, b.first); return Compare::operator()(a.first, b.first);
} }
......
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
// @author: Xin Liu <xliux@fb.com> // @author: Xin Liu <xliux@fb.com>
#include <map> #include <map>
#include <random>
#include <set> #include <set>
#include <thread> #include <thread>
...@@ -53,7 +54,7 @@ static void initData() { ...@@ -53,7 +54,7 @@ static void initData() {
for (int i = 0; i < kMaxValue; ++i) { for (int i = 0; i < kMaxValue; ++i) {
gData[i] = i; gData[i] = i;
} }
std::random_shuffle(gData.begin(), gData.end()); std::shuffle(gData.begin(), gData.end(), std::mt19937{});
} }
// single thread benchmarks // single thread benchmarks
...@@ -374,9 +375,9 @@ class ConcurrentAccessData { ...@@ -374,9 +375,9 @@ class ConcurrentAccessData {
// half new values and half already in the list // half new values and half already in the list
writeValues_.push_back((rand() % 2) + 2 * i); writeValues_.push_back((rand() % 2) + 2 * i);
} }
std::random_shuffle(readValues_.begin(), readValues_.end()); std::shuffle(readValues_.begin(), readValues_.end(), std::mt19937{});
std::random_shuffle(deleteValues_.begin(), deleteValues_.end()); std::shuffle(deleteValues_.begin(), deleteValues_.end(), std::mt19937{});
std::random_shuffle(writeValues_.begin(), writeValues_.end()); std::shuffle(writeValues_.begin(), writeValues_.end(), std::mt19937{});
} }
~ConcurrentAccessData() { ~ConcurrentAccessData() {
......
...@@ -17,14 +17,15 @@ ...@@ -17,14 +17,15 @@
#include <folly/sorted_vector_types.h> #include <folly/sorted_vector_types.h>
#include <gtest/gtest.h> #include <gtest/gtest.h>
#include <list> #include <list>
#include <memory>
using folly::sorted_vector_set; using folly::sorted_vector_set;
using folly::sorted_vector_map; using folly::sorted_vector_map;
namespace { namespace {
template<class T> template <class T>
struct less_invert : std::binary_function<T,T,bool> { struct less_invert {
bool operator()(const T& a, const T& b) const { bool operator()(const T& a, const T& b) const {
return b < a; return b < a;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment