/*============================================================================= Copyright (c) 2011-2019 Bolero MURAKAMI https://github.com/bolero-MURAKAMI/Sprout Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) =============================================================================*/ #ifndef SPROUT_UTILITY_COMPARE_POINTEES_HPP #define SPROUT_UTILITY_COMPARE_POINTEES_HPP #include #include namespace sprout { // // equal_pointees // template inline SPROUT_CONSTEXPR bool equal_pointees(OptionalPointee const& lhs, OptionalPointee const& rhs) { return (!lhs) != (!rhs) ? false : (!lhs ? true : (*lhs) == (*rhs)); } // // not_equal_pointees // template inline SPROUT_CONSTEXPR bool not_equal_pointees(OptionalPointee const& lhs, OptionalPointee const& rhs) { return !sprout::equal_pointees(lhs, rhs); } // // less_pointees // template inline SPROUT_CONSTEXPR bool less_pointees(OptionalPointee const& lhs, OptionalPointee const& rhs) { return !rhs ? false : (!lhs ? true : (*lhs) < (*rhs)); } // // greater_pointees // template inline SPROUT_CONSTEXPR bool greater_pointees(OptionalPointee const& lhs, OptionalPointee const& rhs) { return sprout::less_pointees(rhs, lhs); } // // less_equal_pointees // template inline SPROUT_CONSTEXPR bool less_equal_pointees(OptionalPointee const& lhs, OptionalPointee const& rhs) { return !sprout::less_pointees(rhs, lhs); } // // greater_equal_pointees // template inline SPROUT_CONSTEXPR bool greater_equal_pointees(OptionalPointee const& lhs, OptionalPointee const& rhs) { return !sprout::less_pointees(lhs, rhs); } // // equal_pointees_t // template struct equal_pointees_t : public sprout::binary_function { SPROUT_CONSTEXPR bool operator()(OptionalPointee const& lhs, OptionalPointee const& rhs) const { return sprout::equal_pointees(lhs, rhs); } }; // // not_equal_pointees_t // template struct not_equal_pointees_t : public sprout::binary_function { SPROUT_CONSTEXPR bool operator()(OptionalPointee const& lhs, OptionalPointee const& rhs) const { return sprout::not_equal_pointees(lhs, rhs); } }; // // less_pointees_t // template struct less_pointees_t : public sprout::binary_function { SPROUT_CONSTEXPR bool operator()(OptionalPointee const& lhs, OptionalPointee const& rhs) const { return sprout::less_pointees(lhs, rhs); } }; // // greater_pointees_t // template struct greater_pointees_t : public sprout::binary_function { SPROUT_CONSTEXPR bool operator()(OptionalPointee const& lhs, OptionalPointee const& rhs) const { return sprout::greater_pointees(lhs, rhs); } }; // // less_equal_pointees_t // template struct less_equal_pointees_t : public sprout::binary_function { SPROUT_CONSTEXPR bool operator()(OptionalPointee const& lhs, OptionalPointee const& rhs) const { return sprout::less_equal_pointees(lhs, rhs); } }; // // greater_equal_pointees_t // template struct greater_equal_pointees_t : public sprout::binary_function { SPROUT_CONSTEXPR bool operator()(OptionalPointee const& lhs, OptionalPointee const& rhs) const { return sprout::greater_equal_pointees(lhs, rhs); } }; } // namespace sprout #endif // #ifndef SPROUT_UTILITY_COMPARE_POINTEES_HPP