]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/hana/include/boost/hana/greater.hpp
bump version to 12.2.2-pve1
[ceph.git] / ceph / src / boost / libs / hana / include / boost / hana / greater.hpp
1 /*!
2 @file
3 Defines `boost::hana::greater`.
4
5 @copyright Louis Dionne 2013-2016
6 Distributed under the Boost Software License, Version 1.0.
7 (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)
8 */
9
10 #ifndef BOOST_HANA_GREATER_HPP
11 #define BOOST_HANA_GREATER_HPP
12
13 #include <boost/hana/fwd/greater.hpp>
14
15 #include <boost/hana/concept/orderable.hpp>
16 #include <boost/hana/config.hpp>
17 #include <boost/hana/core/common.hpp>
18 #include <boost/hana/core/to.hpp>
19 #include <boost/hana/core/dispatch.hpp>
20 #include <boost/hana/detail/concepts.hpp>
21 #include <boost/hana/detail/has_common_embedding.hpp>
22 #include <boost/hana/detail/nested_than.hpp> // required by fwd decl
23 #include <boost/hana/if.hpp>
24
25
26 BOOST_HANA_NAMESPACE_BEGIN
27 //! @cond
28 template <typename X, typename Y>
29 constexpr decltype(auto) greater_t::operator()(X&& x, Y&& y) const {
30 using T = typename hana::tag_of<X>::type;
31 using U = typename hana::tag_of<Y>::type;
32 using Greater = BOOST_HANA_DISPATCH_IF(decltype(greater_impl<T, U>{}),
33 hana::Orderable<T>::value &&
34 hana::Orderable<U>::value
35 );
36
37 #ifndef BOOST_HANA_CONFIG_DISABLE_CONCEPT_CHECKS
38 static_assert(hana::Orderable<T>::value,
39 "hana::greater(x, y) requires 'x' to be Orderable");
40
41 static_assert(hana::Orderable<U>::value,
42 "hana::greater(x, y) requires 'y' to be Orderable");
43 #endif
44
45 return Greater::apply(static_cast<X&&>(x), static_cast<Y&&>(y));
46 }
47 //! @endcond
48 template <typename T, typename U, bool condition>
49 struct greater_impl<T, U, when<condition>> : default_ {
50 template <typename X, typename Y>
51 static constexpr decltype(auto) apply(X&& x, Y&& y) {
52 return hana::less(static_cast<Y&&>(y),
53 static_cast<X&&>(x));
54 }
55 };
56
57 // Cross-type overload
58 template <typename T, typename U>
59 struct greater_impl<T, U, when<
60 detail::has_nontrivial_common_embedding<Orderable, T, U>::value
61 >> {
62 using C = typename hana::common<T, U>::type;
63 template <typename X, typename Y>
64 static constexpr decltype(auto) apply(X&& x, Y&& y) {
65 return hana::greater(hana::to<C>(static_cast<X&&>(x)),
66 hana::to<C>(static_cast<Y&&>(y)));
67 }
68 };
69 BOOST_HANA_NAMESPACE_END
70
71 #endif // !BOOST_HANA_GREATER_HPP