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::not_equal`.
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_NOT_EQUAL_HPP
0011 #define BOOST_HANA_NOT_EQUAL_HPP
0012 
0013 #include <boost/hana/fwd/not_equal.hpp>
0014 
0015 #include <boost/hana/concept/comparable.hpp>
0016 #include <boost/hana/config.hpp>
0017 #include <boost/hana/core/to.hpp>
0018 #include <boost/hana/core/dispatch.hpp>
0019 #include <boost/hana/detail/has_common_embedding.hpp>
0020 #include <boost/hana/detail/nested_to.hpp> // required by fwd decl
0021 #include <boost/hana/equal.hpp>
0022 #include <boost/hana/not.hpp>
0023 
0024 
0025 namespace boost { namespace hana {
0026     //! @cond
0027     template <typename X, typename Y>
0028     constexpr auto not_equal_t::operator()(X&& x, Y&& y) const {
0029         using T = typename hana::tag_of<X>::type;
0030         using U = typename hana::tag_of<Y>::type;
0031         using NotEqual = not_equal_impl<T, U>;
0032         return NotEqual::apply(static_cast<X&&>(x), static_cast<Y&&>(y));
0033     }
0034     //! @endcond
0035 
0036     template <typename T, typename U, bool condition>
0037     struct not_equal_impl<T, U, when<condition>> : default_ {
0038         template <typename X, typename Y>
0039         static constexpr decltype(auto) apply(X&& x, Y&& y) {
0040             return hana::not_(hana::equal(static_cast<X&&>(x),
0041                                           static_cast<Y&&>(y)));
0042         }
0043     };
0044 
0045     // Cross-type overload
0046     template <typename T, typename U>
0047     struct not_equal_impl<T, U, when<
0048         detail::has_nontrivial_common_embedding<Comparable, T, U>::value
0049     >> {
0050         using C = typename hana::common<T, U>::type;
0051         template <typename X, typename Y>
0052         static constexpr decltype(auto) apply(X&& x, Y&& y) {
0053             return hana::not_equal(hana::to<C>(static_cast<X&&>(x)),
0054                                    hana::to<C>(static_cast<Y&&>(y)));
0055         }
0056     };
0057 }} // end namespace boost::hana
0058 
0059 #endif // !BOOST_HANA_NOT_EQUAL_HPP