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