Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:38:04

0001 /*!
0002 @file
0003 Defines `boost::hana::ordering`.
0004 
0005 Copyright Louis Dionne 2013-2022
0006 Distributed under the Boost Software License, Version 1.0.
0007 (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)
0008  */
0009 
0010 #ifndef BOOST_HANA_ORDERING_HPP
0011 #define BOOST_HANA_ORDERING_HPP
0012 
0013 #include <boost/hana/fwd/ordering.hpp>
0014 
0015 #include <boost/hana/config.hpp>
0016 #include <boost/hana/detail/decay.hpp>
0017 #include <boost/hana/less.hpp>
0018 
0019 
0020 namespace boost { namespace hana {
0021     namespace detail {
0022         template <typename F>
0023         struct less_by {
0024             F f;
0025 
0026             template <typename X, typename Y>
0027             constexpr decltype(auto) operator()(X&& x, Y&& y) const&
0028             { return hana::less(f(static_cast<X&&>(x)), f(static_cast<Y&&>(y))); }
0029 
0030             template <typename X, typename Y>
0031             constexpr decltype(auto) operator()(X&& x, Y&& y) &
0032             { return hana::less(f(static_cast<X&&>(x)), f(static_cast<Y&&>(y))); }
0033         };
0034     }
0035 
0036     //! @cond
0037     template <typename F>
0038     constexpr auto ordering_t::operator()(F&& f) const {
0039         return detail::less_by<typename detail::decay<F>::type>{static_cast<F&&>(f)};
0040     }
0041     //! @endcond
0042 }} // end namespace boost::hana
0043 
0044 #endif // !BOOST_HANA_ORDERING_HPP