File indexing completed on 2025-01-18 09:38:03
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010 #ifndef BOOST_HANA_GREATER_EQUAL_HPP
0011 #define BOOST_HANA_GREATER_EQUAL_HPP
0012
0013 #include <boost/hana/fwd/greater_equal.hpp>
0014
0015 #include <boost/hana/concept/orderable.hpp>
0016 #include <boost/hana/config.hpp>
0017 #include <boost/hana/core/common.hpp>
0018 #include <boost/hana/core/to.hpp>
0019 #include <boost/hana/core/dispatch.hpp>
0020 #include <boost/hana/detail/concepts.hpp>
0021 #include <boost/hana/detail/has_common_embedding.hpp>
0022 #include <boost/hana/detail/nested_than.hpp> // required by fwd decl
0023 #include <boost/hana/if.hpp>
0024 #include <boost/hana/not.hpp>
0025
0026
0027 namespace boost { namespace hana {
0028
0029 template <typename X, typename Y>
0030 constexpr decltype(auto) greater_equal_t::operator()(X&& x, Y&& y) const {
0031 using T = typename hana::tag_of<X>::type;
0032 using U = typename hana::tag_of<Y>::type;
0033 using GreaterEqual = BOOST_HANA_DISPATCH_IF(
0034 decltype(greater_equal_impl<T, U>{}),
0035 hana::Orderable<T>::value &&
0036 hana::Orderable<U>::value
0037 );
0038
0039 #ifndef BOOST_HANA_CONFIG_DISABLE_CONCEPT_CHECKS
0040 static_assert(hana::Orderable<T>::value,
0041 "hana::greater_equal(x, y) requires 'x' to be Orderable");
0042
0043 static_assert(hana::Orderable<U>::value,
0044 "hana::greater_equal(x, y) requires 'y' to be Orderable");
0045 #endif
0046
0047 return GreaterEqual::apply(static_cast<X&&>(x), static_cast<Y&&>(y));
0048 }
0049
0050
0051 template <typename T, typename U, bool condition>
0052 struct greater_equal_impl<T, U, when<condition>> : default_ {
0053 template <typename X, typename Y>
0054 static constexpr decltype(auto) apply(X x, Y y) {
0055 return hana::not_(hana::less(static_cast<X&&>(x),
0056 static_cast<Y&&>(y)));
0057 }
0058 };
0059
0060
0061 template <typename T, typename U>
0062 struct greater_equal_impl<T, U, when<
0063 detail::has_nontrivial_common_embedding<Orderable, T, U>::value
0064 >> {
0065 using C = typename hana::common<T, U>::type;
0066 template <typename X, typename Y>
0067 static constexpr decltype(auto) apply(X&& x, Y&& y) {
0068 return hana::greater_equal(hana::to<C>(static_cast<X&&>(x)),
0069 hana::to<C>(static_cast<Y&&>(y)));
0070 }
0071 };
0072 }}
0073
0074 #endif