Commit ae57e3b7 authored by Steve O'Brien's avatar Steve O'Brien Committed by Facebook Github Bot

folly/Range: drop include of boost/operators

Summary: Drop this expensive include and just implement the operators.

Reviewed By: yfeldblum

Differential Revision: D7803316

fbshipit-source-id: 969fef54204cf3caa09d67e05be61c3c9a14b67e
parent 97705d14
......@@ -25,7 +25,6 @@
#include <folly/portability/Constexpr.h>
#include <folly/portability/String.h>
#include <boost/operators.hpp>
#include <glog/logging.h>
#include <algorithm>
#include <array>
......@@ -166,7 +165,7 @@ struct IsCharPointer<const char*> {
* wouldn't.)
*/
template <class Iter>
class Range : private boost::totally_ordered<Range<Iter>> {
class Range {
public:
typedef std::size_t size_type;
typedef Iter iterator;
......@@ -1081,11 +1080,31 @@ inline bool operator==(const Range<Iter>& lhs, const Range<Iter>& rhs) {
return lhs.size() == rhs.size() && lhs.compare(rhs) == 0;
}
template <class Iter>
inline bool operator!=(const Range<Iter>& lhs, const Range<Iter>& rhs) {
return !(operator==(lhs, rhs));
}
template <class Iter>
inline bool operator<(const Range<Iter>& lhs, const Range<Iter>& rhs) {
return lhs.compare(rhs) < 0;
}
template <class Iter>
inline bool operator<=(const Range<Iter>& lhs, const Range<Iter>& rhs) {
return lhs.compare(rhs) <= 0;
}
template <class Iter>
inline bool operator>(const Range<Iter>& lhs, const Range<Iter>& rhs) {
return lhs.compare(rhs) > 0;
}
template <class Iter>
inline bool operator>=(const Range<Iter>& lhs, const Range<Iter>& rhs) {
return lhs.compare(rhs) >= 0;
}
/**
* Specializations of comparison operators for StringPiece
*/
......@@ -1113,6 +1132,15 @@ operator==(const T& lhs, const U& rhs) {
return StringPiece(lhs) == StringPiece(rhs);
}
/**
* operator!= through conversion for Range<const char*>
*/
template <class T, class U>
_t<std::enable_if<detail::ComparableAsStringPiece<T, U>::value, bool>>
operator!=(const T& lhs, const U& rhs) {
return StringPiece(lhs) != StringPiece(rhs);
}
/**
* operator< through conversion for Range<const char*>
*/
......
......@@ -106,6 +106,7 @@
#include <vector>
#include <boost/container/flat_map.hpp>
#include <boost/operators.hpp>
#include <folly/Exception.h>
#include <folly/File.h>
......
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