set_value_member.hpp
7.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
//
// traits/set_value_member.hpp
// ~~~~~~~~~~~~~~~~~~~~~~~~~
//
// Copyright (c) 2003-2020 Christopher M. Kohlhoff (chris at kohlhoff dot com)
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
#ifndef ASIO_TRAITS_SET_VALUE_MEMBER_HPP
#define ASIO_TRAITS_SET_VALUE_MEMBER_HPP
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
# pragma once
#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
#include "asio/detail/config.hpp"
#include "asio/detail/type_traits.hpp"
#include "asio/detail/variadic_templates.hpp"
#if defined(ASIO_HAS_DECLTYPE) \
&& defined(ASIO_HAS_NOEXCEPT) \
&& defined(ASIO_HAS_WORKING_EXPRESSION_SFINAE)
# define ASIO_HAS_DEDUCED_SET_VALUE_MEMBER_TRAIT 1
#endif // defined(ASIO_HAS_DECLTYPE)
// && defined(ASIO_HAS_NOEXCEPT)
// && defined(ASIO_HAS_WORKING_EXPRESSION_SFINAE)
#include "asio/detail/push_options.hpp"
namespace asio {
namespace traits {
template <typename T, typename Vs, typename = void>
struct set_value_member_default;
template <typename T, typename Vs, typename = void>
struct set_value_member;
} // namespace traits
namespace detail {
struct no_set_value_member
{
ASIO_STATIC_CONSTEXPR(bool, is_valid = false);
ASIO_STATIC_CONSTEXPR(bool, is_noexcept = false);
};
#if defined(ASIO_HAS_DEDUCED_SET_VALUE_MEMBER_TRAIT)
template <typename T, typename Vs, typename = void>
struct set_value_member_trait : no_set_value_member
{
};
#if defined(ASIO_HAS_VARIADIC_TEMPLATES)
template <typename T, typename... Vs>
struct set_value_member_trait<T, void(Vs...),
typename void_type<
decltype(declval<T>().set_value(declval<Vs>()...))
>::type>
{
ASIO_STATIC_CONSTEXPR(bool, is_valid = true);
using result_type = decltype(
declval<T>().set_value(declval<Vs>()...));
ASIO_STATIC_CONSTEXPR(bool, is_noexcept = noexcept(
declval<T>().set_value(declval<Vs>()...)));
};
#else // defined(ASIO_HAS_VARIADIC_TEMPLATES)
template <typename T>
struct set_value_member_trait<T, void(),
typename void_type<
decltype(declval<T>().set_value())
>::type>
{
ASIO_STATIC_CONSTEXPR(bool, is_valid = true);
using result_type = decltype(declval<T>().set_value());
ASIO_STATIC_CONSTEXPR(bool,
is_noexcept = noexcept(declval<T>().set_value()));
};
#define ASIO_PRIVATE_SET_VALUE_MEMBER_TRAIT_DEF(n) \
template <typename T, ASIO_VARIADIC_TPARAMS(n)> \
struct set_value_member_trait<T, void(ASIO_VARIADIC_TARGS(n)), \
typename void_type< \
decltype(declval<T>().set_value(ASIO_VARIADIC_DECLVAL(n))) \
>::type> \
{ \
ASIO_STATIC_CONSTEXPR(bool, is_valid = true); \
\
using result_type = decltype( \
declval<T>().set_value(ASIO_VARIADIC_DECLVAL(n))); \
\
ASIO_STATIC_CONSTEXPR(bool, is_noexcept = noexcept( \
declval<T>().set_value(ASIO_VARIADIC_DECLVAL(n)))); \
}; \
/**/
ASIO_VARIADIC_GENERATE(ASIO_PRIVATE_SET_VALUE_MEMBER_TRAIT_DEF)
#undef ASIO_PRIVATE_SET_VALUE_MEMBER_TRAIT_DEF
#endif // defined(ASIO_HAS_VARIADIC_TEMPLATES)
#else // defined(ASIO_HAS_DEDUCED_SET_VALUE_MEMBER_TRAIT)
template <typename T, typename Vs, typename = void>
struct set_value_member_trait;
#if defined(ASIO_HAS_VARIADIC_TEMPLATES)
template <typename T, typename... Vs>
struct set_value_member_trait<T, void(Vs...)> :
conditional<
is_same<T, typename remove_reference<T>::type>::value
&& conjunction<is_same<Vs, typename decay<Vs>::type>...>::value,
typename conditional<
is_same<T, typename add_const<T>::type>::value,
no_set_value_member,
traits::set_value_member<typename add_const<T>::type, void(Vs...)>
>::type,
traits::set_value_member<
typename remove_reference<T>::type,
void(typename decay<Vs>::type...)>
>::type
{
};
#else // defined(ASIO_HAS_VARIADIC_TEMPLATES)
template <typename T>
struct set_value_member_trait<T, void()> :
conditional<
is_same<T, typename remove_reference<T>::type>::value,
typename conditional<
is_same<T, typename add_const<T>::type>::value,
no_set_value_member,
traits::set_value_member<typename add_const<T>::type, void()>
>::type,
traits::set_value_member<typename remove_reference<T>::type, void()>
>::type
{
};
#define ASIO_PRIVATE_SET_VALUE_MEMBER_IS_SAME(n) \
ASIO_PRIVATE_SET_VALUE_MEMBER_IS_SAME_##n
#define ASIO_PRIVATE_SET_VALUE_MEMBER_IS_SAME_1 \
&& is_same<T1, typename decay<T1>::type>::value
#define ASIO_PRIVATE_SET_VALUE_MEMBER_IS_SAME_2 \
ASIO_PRIVATE_SET_VALUE_MEMBER_IS_SAME_1 \
&& is_same<T2, typename decay<T2>::type>::value
#define ASIO_PRIVATE_SET_VALUE_MEMBER_IS_SAME_3 \
ASIO_PRIVATE_SET_VALUE_MEMBER_IS_SAME_2 \
&& is_same<T3, typename decay<T3>::type>::value
#define ASIO_PRIVATE_SET_VALUE_MEMBER_IS_SAME_4 \
ASIO_PRIVATE_SET_VALUE_MEMBER_IS_SAME_3 \
&& is_same<T4, typename decay<T4>::type>::value
#define ASIO_PRIVATE_SET_VALUE_MEMBER_IS_SAME_5 \
ASIO_PRIVATE_SET_VALUE_MEMBER_IS_SAME_4 \
&& is_same<T5, typename decay<T5>::type>::value
#define ASIO_PRIVATE_SET_VALUE_MEMBER_IS_SAME_6 \
ASIO_PRIVATE_SET_VALUE_MEMBER_IS_SAME_5 \
&& is_same<T6, typename decay<T6>::type>::value
#define ASIO_PRIVATE_SET_VALUE_MEMBER_IS_SAME_7 \
ASIO_PRIVATE_SET_VALUE_MEMBER_IS_SAME_6 \
&& is_same<T7, typename decay<T7>::type>::value
#define ASIO_PRIVATE_SET_VALUE_MEMBER_IS_SAME_8 \
ASIO_PRIVATE_SET_VALUE_MEMBER_IS_SAME_7 \
&& is_same<T8, typename decay<T8>::type>::value
#define ASIO_PRIVATE_SET_VALUE_MEMBER_TRAIT_DEF(n) \
template <typename T, ASIO_VARIADIC_TPARAMS(n)> \
struct set_value_member_trait<T, void(ASIO_VARIADIC_TARGS(n))> : \
conditional< \
is_same<T, typename remove_reference<T>::type>::value \
ASIO_PRIVATE_SET_VALUE_MEMBER_IS_SAME(n), \
typename conditional< \
is_same<T, typename add_const<T>::type>::value, \
no_set_value_member, \
traits::set_value_member< \
typename add_const<T>::type, \
void(ASIO_VARIADIC_TARGS(n))> \
>::type, \
traits::set_value_member< \
typename remove_reference<T>::type, \
void(ASIO_VARIADIC_DECAY(n))> \
>::type \
{ \
}; \
/**/
ASIO_VARIADIC_GENERATE(ASIO_PRIVATE_SET_VALUE_MEMBER_TRAIT_DEF)
#undef ASIO_PRIVATE_SET_VALUE_MEMBER_TRAIT_DEF
#undef ASIO_PRIVATE_SET_VALUE_MEMBER_IS_SAME
#undef ASIO_PRIVATE_SET_VALUE_MEMBER_IS_SAME_1
#undef ASIO_PRIVATE_SET_VALUE_MEMBER_IS_SAME_2
#undef ASIO_PRIVATE_SET_VALUE_MEMBER_IS_SAME_3
#undef ASIO_PRIVATE_SET_VALUE_MEMBER_IS_SAME_4
#undef ASIO_PRIVATE_SET_VALUE_MEMBER_IS_SAME_5
#undef ASIO_PRIVATE_SET_VALUE_MEMBER_IS_SAME_6
#undef ASIO_PRIVATE_SET_VALUE_MEMBER_IS_SAME_7
#undef ASIO_PRIVATE_SET_VALUE_MEMBER_IS_SAME_8
#endif // defined(ASIO_HAS_VARIADIC_TEMPLATES)
#endif // defined(ASIO_HAS_DEDUCED_SET_VALUE_MEMBER_TRAIT)
} // namespace detail
namespace traits {
template <typename T, typename Vs, typename>
struct set_value_member_default :
detail::set_value_member_trait<T, Vs>
{
};
template <typename T, typename Vs, typename>
struct set_value_member :
set_value_member_default<T, Vs>
{
};
} // namespace traits
} // namespace asio
#include "asio/detail/pop_options.hpp"
#endif // ASIO_TRAITS_SET_VALUE_MEMBER_HPP