]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | /*! |
2 | @file | |
3 | Defines `boost::hana::ordering`. | |
4 | ||
b32b8144 | 5 | @copyright Louis Dionne 2013-2017 |
7c673cae FG |
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_ORDERING_HPP | |
11 | #define BOOST_HANA_ORDERING_HPP | |
12 | ||
13 | #include <boost/hana/fwd/ordering.hpp> | |
14 | ||
15 | #include <boost/hana/config.hpp> | |
16 | #include <boost/hana/detail/decay.hpp> | |
17 | #include <boost/hana/less.hpp> | |
18 | ||
19 | ||
20 | BOOST_HANA_NAMESPACE_BEGIN | |
21 | namespace detail { | |
22 | template <typename F> | |
23 | struct less_by { | |
24 | F f; | |
25 | ||
26 | template <typename X, typename Y> | |
27 | constexpr decltype(auto) operator()(X&& x, Y&& y) const& | |
28 | { return hana::less(f(static_cast<X&&>(x)), f(static_cast<Y&&>(y))); } | |
29 | ||
30 | template <typename X, typename Y> | |
31 | constexpr decltype(auto) operator()(X&& x, Y&& y) & | |
32 | { return hana::less(f(static_cast<X&&>(x)), f(static_cast<Y&&>(y))); } | |
33 | }; | |
34 | } | |
35 | ||
36 | //! @cond | |
37 | template <typename F> | |
38 | constexpr auto ordering_t::operator()(F&& f) const { | |
39 | return detail::less_by<typename detail::decay<F>::type>{static_cast<F&&>(f)}; | |
40 | } | |
41 | //! @endcond | |
42 | BOOST_HANA_NAMESPACE_END | |
43 | ||
44 | #endif // !BOOST_HANA_ORDERING_HPP |