Clementine
static_require.hpp
1 //
2 // traits/static_require.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_STATIC_REQUIRE_HPP
12 #define ASIO_TRAITS_STATIC_REQUIRE_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 #include "asio/traits/static_query.hpp"
21 
22 #if defined(ASIO_HAS_DECLTYPE) \
23  && defined(ASIO_HAS_NOEXCEPT)
24 # define ASIO_HAS_DEDUCED_STATIC_REQUIRE_TRAIT 1
25 #endif // defined(ASIO_HAS_DECLTYPE)
26  // && defined(ASIO_HAS_NOEXCEPT)
27 
28 #include "asio/detail/push_options.hpp"
29 
30 namespace asio {
31 namespace traits {
32 
33 template <typename T, typename Property, typename = void>
35 
36 template <typename T, typename Property, typename = void>
38 
39 } // namespace traits
40 namespace detail {
41 
43 {
44  ASIO_STATIC_CONSTEXPR(bool, is_valid = false);
45 };
46 
47 template <typename T, typename Property, typename = void>
49  conditional<
50  is_same<T, typename decay<T>::type>::value
51  && is_same<Property, typename decay<Property>::type>::value,
52  no_static_require,
53  traits::static_require<
54  typename decay<T>::type,
55  typename decay<Property>::type>
56  >::type
57 {
58 };
59 
60 #if defined(ASIO_HAS_DEDUCED_STATIC_REQUIRE_TRAIT)
61 
62 #if defined(ASIO_HAS_WORKING_EXPRESSION_SFINAE)
63 
64 template <typename T, typename Property>
65 struct static_require_trait<T, Property,
66  typename enable_if<
67  decay<Property>::type::value() == traits::static_query<T, Property>::value()
68  >::type>
69 {
70  ASIO_STATIC_CONSTEXPR(bool, is_valid = true);
71 };
72 
73 #else // defined(ASIO_HAS_WORKING_EXPRESSION_SFINAE)
74 
75 false_type static_require_test(...);
76 
77 template <typename T, typename Property>
78 true_type static_require_test(T*, Property*,
79  typename enable_if<
80  Property::value() == traits::static_query<T, Property>::value()
81  >::type* = 0);
82 
83 template <typename T, typename Property>
84 struct has_static_require
85 {
86  ASIO_STATIC_CONSTEXPR(bool, value =
87  decltype((static_require_test)(
88  static_cast<T*>(0), static_cast<Property*>(0)))::value);
89 };
90 
91 template <typename T, typename Property>
92 struct static_require_trait<T, Property,
93  typename enable_if<
94  has_static_require<typename decay<T>::type,
95  typename decay<Property>::type>::value
96  >::type>
97 {
98  ASIO_STATIC_CONSTEXPR(bool, is_valid = true);
99 };
100 
101 #endif // defined(ASIO_HAS_WORKING_EXPRESSION_SFINAE)
102 
103 #endif // defined(ASIO_HAS_DEDUCED_STATIC_REQUIRE_TRAIT)
104 
105 } // namespace detail
106 namespace traits {
107 
108 template <typename T, typename Property, typename>
109 struct static_require_default : detail::static_require_trait<T, Property>
110 {
111 };
112 
113 template <typename T, typename Property, typename>
114 struct static_require : static_require_default<T, Property>
115 {
116 };
117 
118 } // namespace traits
119 } // namespace asio
120 
121 #include "asio/detail/pop_options.hpp"
122 
123 #endif // ASIO_TRAITS_STATIC_REQUIRE_HPP
Definition: static_require.hpp:37
Definition: static_query.hpp:42
Definition: chrono.h:284
Definition: static_require.hpp:34
Definition: any_io_executor.hpp:28
Definition: static_require.hpp:42
Definition: static_require.hpp:48