]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | /*! |
2 | @file | |
3 | Defines operators for Comparables. | |
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_DETAIL_OPERATORS_COMPARABLE_HPP | |
11 | #define BOOST_HANA_DETAIL_OPERATORS_COMPARABLE_HPP | |
12 | ||
13 | #include <boost/hana/config.hpp> | |
14 | #include <boost/hana/core/tag_of.hpp> | |
15 | #include <boost/hana/fwd/equal.hpp> | |
16 | #include <boost/hana/fwd/not_equal.hpp> | |
17 | ||
18 | #include <type_traits> | |
19 | ||
20 | ||
21 | BOOST_HANA_NAMESPACE_BEGIN namespace detail { | |
22 | template <typename Tag> | |
23 | struct comparable_operators { | |
24 | static constexpr bool value = false; | |
25 | }; | |
26 | ||
27 | namespace operators { | |
28 | template <typename X, typename Y, typename = typename std::enable_if< | |
29 | detail::comparable_operators<typename hana::tag_of<X>::type>::value || | |
30 | detail::comparable_operators<typename hana::tag_of<Y>::type>::value | |
31 | >::type> | |
32 | constexpr auto operator==(X&& x, Y&& y) | |
33 | { return hana::equal(static_cast<X&&>(x), static_cast<Y&&>(y)); } | |
34 | ||
35 | template <typename X, typename Y, typename = typename std::enable_if< | |
36 | detail::comparable_operators<typename hana::tag_of<X>::type>::value || | |
37 | detail::comparable_operators<typename hana::tag_of<Y>::type>::value | |
38 | >::type> | |
39 | constexpr auto operator!=(X&& x, Y&& y) | |
40 | { return hana::not_equal(static_cast<X&&>(x), static_cast<Y&&>(y)); } | |
41 | } // end namespace operators | |
42 | } BOOST_HANA_NAMESPACE_END | |
43 | ||
44 | #endif // !BOOST_HANA_DETAIL_OPERATORS_COMPARABLE_HPP |