diff --git a/third-party/thrift/src/thrift/lib/cpp2/op/detail/Compare.h b/third-party/thrift/src/thrift/lib/cpp2/op/detail/Compare.h index 1890f888ec8446..1efadc1b0e1dbc 100644 --- a/third-party/thrift/src/thrift/lib/cpp2/op/detail/Compare.h +++ b/third-party/thrift/src/thrift/lib/cpp2/op/detail/Compare.h @@ -399,45 +399,6 @@ template l.begin(), l.end(), r.begin(), r.end(), less); } -template -constexpr auto lexicographicalCompareThreeWay( - I1 f1, I1 l1, I2 f2, I2 l2, Cmp comp) -> decltype(comp(*f1, *f2)) { - auto exhaust1 = [&] { return f1 == l1; }; - auto exhaust2 = [&] { return f2 == l2; }; - for (; !exhaust1() && !exhaust2(); ++f1, ++f2) { - if (auto c = comp(*f1, *f2); c != folly::ordering::eq) { - return c; - } - } - - return !exhaust1() ? folly::ordering::gt - : !exhaust2() ? folly::ordering::lt - : folly::ordering::eq; -} - -template -[[maybe_unused]] constexpr folly::ordering -sortAndLexicographicalCompareThreeWay( - const T& lhs, const T& rhs, Comp&& comp, CmpThreeWay&& cmp_three_way) { - std::vector l, r; - for (auto i = lhs.begin(); i != lhs.end(); ++i) { - l.push_back(i); - } - for (auto i = rhs.begin(); i != rhs.end(); ++i) { - r.push_back(i); - } - auto less = [&](auto lhsIter, auto rhsIter) { - return comp(*lhsIter, *rhsIter); - }; - auto compare_three_way = [&](auto lhsIter, auto rhsIter) { - return cmp_three_way(*lhsIter, *rhsIter); - }; - std::sort(l.begin(), l.end(), less); - std::sort(r.begin(), r.end(), less); - return lexicographicalCompareThreeWay( - l.begin(), l.end(), r.begin(), r.end(), compare_three_way); -} - template class LessThanImpl = LessThan> struct ListLessThan { bool operator()(const T& l, const T& r) const { @@ -702,48 +663,6 @@ struct EqualTo>> template struct IdenticalTo> : IdenticalTo {}; -template -struct CompareThreeWay, type::list> { - template >> - folly::ordering operator()(const T& l, const T& r) const { - return lexicographicalCompareThreeWay( - l.begin(), l.end(), r.begin(), r.end(), CompareThreeWay{}); - } -}; - -template -struct CompareThreeWay, type::set> { - template >> - folly::ordering operator()(const T& l, const T& r) const { - return lexicographicalCompareThreeWay( - l.begin(), l.end(), r.begin(), r.end(), CompareThreeWay{}); - } -}; - -template -struct CompareThreeWay, type::map> { - template >> - folly::ordering operator()(const T& lhs, const T& rhs) const { - auto less = [](const auto& l, const auto& r) { - auto ret = CompareThreeWay{}(l.first, r.first); - if (ret == folly::ordering::eq) { - ret = CompareThreeWay{}(l.second, r.second); - } - return ret == folly::ordering::lt; - }; - auto compare_three_way = [](const auto& l, const auto& r) { - auto ret = CompareThreeWay{}(l.first, r.first); - if (ret != folly::ordering::eq) { - return ret; - } - return CompareThreeWay{}(l.second, r.second); - }; - - return sortAndLexicographicalCompareThreeWay( - lhs, rhs, less, compare_three_way); - } -}; - // Hooks for adapted types. template struct EqualTo> {