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
#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 {
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);
}
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);
}
// @author: Xin Liu <xliux@fb.com>
#include <map>
+#include <random>
#include <set>
#include <thread>
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
// 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() {
#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;
}