/* * Copyright (c) Facebook, Inc. and its affiliates. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #pragma once namespace folly { enum class ordering : int { lt = -1, eq = 0, gt = 1 }; template constexpr ordering to_ordering(T c) { return ordering(int(c < T(0)) * -1 + int(c > T(0))); } namespace detail { template struct cmp_pred : private C { using C::C; template constexpr bool operator()(A&& a, B&& b) const { return ne ^ (C::operator()(static_cast(a), static_cast(b)) == o); } }; } // namespace detail template struct compare_equal_to : detail::cmp_pred { using detail::cmp_pred::cmp_pred; }; template struct compare_not_equal_to : detail::cmp_pred { using detail::cmp_pred::cmp_pred; }; template struct compare_less : detail::cmp_pred { using detail::cmp_pred::cmp_pred; }; template struct compare_less_equal : detail::cmp_pred { using detail::cmp_pred::cmp_pred; }; template struct compare_greater : detail::cmp_pred { using detail::cmp_pred::cmp_pred; }; template struct compare_greater_equal : detail::cmp_pred { using detail::cmp_pred::cmp_pred; }; } // namespace folly