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