Clementine
equality_comparable.hpp
1 //
2 // traits/equality_comparable.hpp
3 // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
4 //
5 // Copyright (c) 2003-2020 Christopher M. Kohlhoff (chris at kohlhoff dot com)
6 //
7 // Distributed under the Boost Software License, Version 1.0. (See accompanying
8 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
9 //
10 
11 #ifndef ASIO_TRAITS_EQUALITY_COMPARABLE_HPP
12 #define ASIO_TRAITS_EQUALITY_COMPARABLE_HPP
13 
14 #if defined(_MSC_VER) && (_MSC_VER >= 1200)
15 # pragma once
16 #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
17 
18 #include "asio/detail/config.hpp"
19 #include "asio/detail/type_traits.hpp"
20 
21 #if defined(ASIO_HAS_DECLTYPE) \
22  && defined(ASIO_HAS_NOEXCEPT) \
23  && defined(ASIO_HAS_WORKING_EXPRESSION_SFINAE)
24 # define ASIO_HAS_DEDUCED_EQUALITY_COMPARABLE_TRAIT 1
25 #endif // defined(ASIO_HAS_DECLTYPE)
26  // && defined(ASIO_HAS_NOEXCEPT)
27  // && defined(ASIO_HAS_WORKING_EXPRESSION_SFINAE)
28 
29 namespace asio {
30 namespace traits {
31 
32 template <typename T, typename = void>
34 
35 template <typename T, typename = void>
37 
38 } // namespace traits
39 namespace detail {
40 
42 {
43  ASIO_STATIC_CONSTEXPR(bool, is_valid = false);
44  ASIO_STATIC_CONSTEXPR(bool, is_noexcept = false);
45 };
46 
47 #if defined(ASIO_HAS_DEDUCED_EQUALITY_COMPARABLE_TRAIT)
48 
49 template <typename T, typename = void>
51 {
52 };
53 
54 template <typename T>
56  typename void_type<
57  decltype(
58  static_cast<void>(
59  static_cast<bool>(declval<const T>() == declval<const T>())
60  ),
61  static_cast<void>(
62  static_cast<bool>(declval<const T>() != declval<const T>())
63  )
64  )
65  >::type>
66 {
67  ASIO_STATIC_CONSTEXPR(bool, is_valid = true);
68 
69  ASIO_STATIC_CONSTEXPR(bool, is_noexcept =
70  noexcept(declval<const T>() == declval<const T>())
71  && noexcept(declval<const T>() != declval<const T>()));
72 };
73 
74 #else // defined(ASIO_HAS_DEDUCED_EQUALITY_COMPARABLE_TRAIT)
75 
76 template <typename T, typename = void>
78  conditional<
79  is_same<T, typename decay<T>::type>::value,
80  no_equality_comparable,
81  traits::equality_comparable<typename decay<T>::type>
82  >::type
83 {
84 };
85 
86 #endif // defined(ASIO_HAS_DEDUCED_EQUALITY_COMPARABLE_TRAIT)
87 
88 } // namespace detail
89 namespace traits {
90 
91 template <typename T, typename>
92 struct equality_comparable_default : detail::equality_comparable_trait<T>
93 {
94 };
95 
96 template <typename T, typename>
97 struct equality_comparable : equality_comparable_default<T>
98 {
99 };
100 
101 } // namespace traits
102 } // namespace asio
103 
104 #endif // ASIO_TRAITS_EQUALITY_COMPARABLE_HPP
Definition: equality_comparable.hpp:41
Definition: chrono.h:284
Definition: equality_comparable.hpp:77
Definition: equality_comparable.hpp:33
Definition: any_io_executor.hpp:28
Definition: equality_comparable.hpp:36