Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-12-15 09:52:46

0001 /*!
0002 @file
0003 Defines concepts from the Standard library.
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_DETAIL_CONCEPTS_HPP
0011 #define BOOST_HANA_DETAIL_CONCEPTS_HPP
0012 
0013 #include <boost/hana/config.hpp>
0014 #include <boost/hana/detail/std_common_type.hpp>
0015 #include <boost/hana/detail/void_t.hpp>
0016 
0017 #include <type_traits>
0018 
0019 
0020 namespace boost { namespace hana { namespace detail {
0021     //! @cond
0022     //////////////////////////////////////////////////////////////////////////
0023     // EqualityComparable
0024     //////////////////////////////////////////////////////////////////////////
0025     template <typename T, typename U = T, typename = void>
0026     struct EqualityComparable : std::false_type { };
0027 
0028     template <typename T>
0029     struct EqualityComparable<T, T, detail::void_t<
0030         decltype(static_cast<T&&>(*(T*)0) == static_cast<T&&>(*(T*)0) ? 0:0),
0031         decltype(static_cast<T&&>(*(T*)0) != static_cast<T&&>(*(T*)0) ? 0:0)
0032     >> : std::true_type { };
0033 
0034     template <typename T, typename U>
0035     struct EqualityComparable<T, U, typename std::enable_if<
0036         !std::is_same<T, U>::value, detail::void_t<
0037             decltype(static_cast<T&&>(*(T*)0) == static_cast<U&&>(*(U*)0) ? 0:0),
0038             decltype(static_cast<U&&>(*(U*)0) == static_cast<T&&>(*(T*)0) ? 0:0),
0039             decltype(static_cast<T&&>(*(T*)0) != static_cast<U&&>(*(U*)0) ? 0:0),
0040             decltype(static_cast<U&&>(*(U*)0) != static_cast<T&&>(*(T*)0) ? 0:0),
0041             typename detail::std_common_type<T, U>::type
0042     >>::type> : std::integral_constant<bool,
0043         EqualityComparable<T>::value &&
0044         EqualityComparable<U>::value &&
0045         EqualityComparable<typename detail::std_common_type<T, U>::type>::value
0046     > { };
0047 
0048 
0049     //////////////////////////////////////////////////////////////////////////
0050     // LessThanComparable
0051     //////////////////////////////////////////////////////////////////////////
0052     template <typename T, typename U = T, typename = void>
0053     struct LessThanComparable : std::false_type { };
0054 
0055     template <typename T>
0056     struct LessThanComparable<T, T, detail::void_t<
0057         decltype(static_cast<T&&>(*(T*)0) < static_cast<T&&>(*(T*)0) ? 0:0)
0058     >> : std::true_type { };
0059 
0060     template <typename T, typename U>
0061     struct LessThanComparable<T, U, std::enable_if_t<
0062         !std::is_same<T, U>::value,
0063         detail::void_t<
0064             decltype(static_cast<T&&>(*(T*)0) < static_cast<U&&>(*(U*)0) ? 0:0),
0065             decltype(static_cast<U&&>(*(U*)0) < static_cast<T&&>(*(T*)0) ? 0:0),
0066             typename detail::std_common_type<T, U>::type
0067         >
0068     >>
0069         : std::integral_constant<bool,
0070             LessThanComparable<T>::value &&
0071             LessThanComparable<U>::value &&
0072             LessThanComparable<typename detail::std_common_type<T, U>::type>::value
0073         >
0074     { };
0075     //! @endcond
0076 } }} // end namespace boost::hana
0077 
0078 #endif // !BOOST_HANA_DETAIL_CONCEPTS_HPP