File indexing completed on 2025-01-18 09:29:02
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011 #ifndef BOOST_ASIO_TRAITS_EQUALITY_COMPARABLE_HPP
0012 #define BOOST_ASIO_TRAITS_EQUALITY_COMPARABLE_HPP
0013
0014 #if defined(_MSC_VER) && (_MSC_VER >= 1200)
0015 # pragma once
0016 #endif
0017
0018 #include <boost/asio/detail/config.hpp>
0019 #include <boost/asio/detail/type_traits.hpp>
0020
0021 #if defined(BOOST_ASIO_HAS_WORKING_EXPRESSION_SFINAE)
0022 # define BOOST_ASIO_HAS_DEDUCED_EQUALITY_COMPARABLE_TRAIT 1
0023 #endif
0024
0025 namespace boost {
0026 namespace asio {
0027 namespace traits {
0028
0029 template <typename T, typename = void>
0030 struct equality_comparable_default;
0031
0032 template <typename T, typename = void>
0033 struct equality_comparable;
0034
0035 }
0036 namespace detail {
0037
0038 struct no_equality_comparable
0039 {
0040 static constexpr bool is_valid = false;
0041 static constexpr bool is_noexcept = false;
0042 };
0043
0044 #if defined(BOOST_ASIO_HAS_DEDUCED_EQUALITY_COMPARABLE_TRAIT)
0045
0046 template <typename T, typename = void>
0047 struct equality_comparable_trait : no_equality_comparable
0048 {
0049 };
0050
0051 template <typename T>
0052 struct equality_comparable_trait<T,
0053 void_t<
0054 decltype(
0055 static_cast<void>(
0056 static_cast<bool>(declval<const T>() == declval<const T>())
0057 ),
0058 static_cast<void>(
0059 static_cast<bool>(declval<const T>() != declval<const T>())
0060 )
0061 )
0062 >>
0063 {
0064 static constexpr bool is_valid = true;
0065
0066 static constexpr bool is_noexcept =
0067 noexcept(declval<const T>() == declval<const T>())
0068 && noexcept(declval<const T>() != declval<const T>());
0069 };
0070
0071 #else
0072
0073 template <typename T, typename = void>
0074 struct equality_comparable_trait :
0075 conditional_t<
0076 is_same<T, decay_t<T>>::value,
0077 no_equality_comparable,
0078 traits::equality_comparable<decay_t<T>>
0079 >
0080 {
0081 };
0082
0083 #endif
0084
0085 }
0086 namespace traits {
0087
0088 template <typename T, typename>
0089 struct equality_comparable_default : detail::equality_comparable_trait<T>
0090 {
0091 };
0092
0093 template <typename T, typename>
0094 struct equality_comparable : equality_comparable_default<T>
0095 {
0096 };
0097
0098 }
0099 }
0100 }
0101
0102 #endif