File indexing completed on 2025-01-18 09:28:41
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011 #ifndef BOOST_ASIO_DETAIL_IS_BUFFER_SEQUENCE_HPP
0012 #define BOOST_ASIO_DETAIL_IS_BUFFER_SEQUENCE_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 #include <boost/asio/detail/push_options.hpp>
0022
0023 namespace boost {
0024 namespace asio {
0025
0026 class mutable_buffer;
0027 class const_buffer;
0028 class mutable_registered_buffer;
0029 class const_registered_buffer;
0030
0031 namespace detail {
0032
0033 struct buffer_sequence_memfns_base
0034 {
0035 void begin();
0036 void end();
0037 void size();
0038 void max_size();
0039 void capacity();
0040 void data();
0041 void prepare();
0042 void commit();
0043 void consume();
0044 void grow();
0045 void shrink();
0046 };
0047
0048 template <typename T>
0049 struct buffer_sequence_memfns_derived
0050 : T, buffer_sequence_memfns_base
0051 {
0052 };
0053
0054 template <typename T, T>
0055 struct buffer_sequence_memfns_check
0056 {
0057 };
0058
0059 template <typename>
0060 char buffer_sequence_begin_helper(...);
0061
0062 template <typename T>
0063 char (&buffer_sequence_begin_helper(T* t,
0064 enable_if_t<!is_same<
0065 decltype(boost::asio::buffer_sequence_begin(*t)),
0066 void>::value>*))[2];
0067
0068 template <typename>
0069 char buffer_sequence_end_helper(...);
0070
0071 template <typename T>
0072 char (&buffer_sequence_end_helper(T* t,
0073 enable_if_t<!is_same<
0074 decltype(boost::asio::buffer_sequence_end(*t)),
0075 void>::value>*))[2];
0076
0077 template <typename>
0078 char (&size_memfn_helper(...))[2];
0079
0080 template <typename T>
0081 char size_memfn_helper(
0082 buffer_sequence_memfns_check<
0083 void (buffer_sequence_memfns_base::*)(),
0084 &buffer_sequence_memfns_derived<T>::size>*);
0085
0086 template <typename>
0087 char (&max_size_memfn_helper(...))[2];
0088
0089 template <typename T>
0090 char max_size_memfn_helper(
0091 buffer_sequence_memfns_check<
0092 void (buffer_sequence_memfns_base::*)(),
0093 &buffer_sequence_memfns_derived<T>::max_size>*);
0094
0095 template <typename>
0096 char (&capacity_memfn_helper(...))[2];
0097
0098 template <typename T>
0099 char capacity_memfn_helper(
0100 buffer_sequence_memfns_check<
0101 void (buffer_sequence_memfns_base::*)(),
0102 &buffer_sequence_memfns_derived<T>::capacity>*);
0103
0104 template <typename>
0105 char (&data_memfn_helper(...))[2];
0106
0107 template <typename T>
0108 char data_memfn_helper(
0109 buffer_sequence_memfns_check<
0110 void (buffer_sequence_memfns_base::*)(),
0111 &buffer_sequence_memfns_derived<T>::data>*);
0112
0113 template <typename>
0114 char (&prepare_memfn_helper(...))[2];
0115
0116 template <typename T>
0117 char prepare_memfn_helper(
0118 buffer_sequence_memfns_check<
0119 void (buffer_sequence_memfns_base::*)(),
0120 &buffer_sequence_memfns_derived<T>::prepare>*);
0121
0122 template <typename>
0123 char (&commit_memfn_helper(...))[2];
0124
0125 template <typename T>
0126 char commit_memfn_helper(
0127 buffer_sequence_memfns_check<
0128 void (buffer_sequence_memfns_base::*)(),
0129 &buffer_sequence_memfns_derived<T>::commit>*);
0130
0131 template <typename>
0132 char (&consume_memfn_helper(...))[2];
0133
0134 template <typename T>
0135 char consume_memfn_helper(
0136 buffer_sequence_memfns_check<
0137 void (buffer_sequence_memfns_base::*)(),
0138 &buffer_sequence_memfns_derived<T>::consume>*);
0139
0140 template <typename>
0141 char (&grow_memfn_helper(...))[2];
0142
0143 template <typename T>
0144 char grow_memfn_helper(
0145 buffer_sequence_memfns_check<
0146 void (buffer_sequence_memfns_base::*)(),
0147 &buffer_sequence_memfns_derived<T>::grow>*);
0148
0149 template <typename>
0150 char (&shrink_memfn_helper(...))[2];
0151
0152 template <typename T>
0153 char shrink_memfn_helper(
0154 buffer_sequence_memfns_check<
0155 void (buffer_sequence_memfns_base::*)(),
0156 &buffer_sequence_memfns_derived<T>::shrink>*);
0157
0158 template <typename, typename>
0159 char (&buffer_sequence_element_type_helper(...))[2];
0160
0161 template <typename T, typename Buffer>
0162 char buffer_sequence_element_type_helper(T* t,
0163 enable_if_t<is_convertible<
0164 decltype(*boost::asio::buffer_sequence_begin(*t)),
0165 Buffer>::value>*);
0166
0167 template <typename>
0168 char (&const_buffers_type_typedef_helper(...))[2];
0169
0170 template <typename T>
0171 char const_buffers_type_typedef_helper(
0172 typename T::const_buffers_type*);
0173
0174 template <typename>
0175 char (&mutable_buffers_type_typedef_helper(...))[2];
0176
0177 template <typename T>
0178 char mutable_buffers_type_typedef_helper(
0179 typename T::mutable_buffers_type*);
0180
0181 template <typename T, typename Buffer>
0182 struct is_buffer_sequence_class
0183 : integral_constant<bool,
0184 sizeof(buffer_sequence_begin_helper<T>(0, 0)) != 1 &&
0185 sizeof(buffer_sequence_end_helper<T>(0, 0)) != 1 &&
0186 sizeof(buffer_sequence_element_type_helper<T, Buffer>(0, 0)) == 1>
0187 {
0188 };
0189
0190 template <typename T, typename Buffer>
0191 struct is_buffer_sequence
0192 : conditional<is_class<T>::value,
0193 is_buffer_sequence_class<T, Buffer>,
0194 false_type>::type
0195 {
0196 };
0197
0198 template <>
0199 struct is_buffer_sequence<mutable_buffer, mutable_buffer>
0200 : true_type
0201 {
0202 };
0203
0204 template <>
0205 struct is_buffer_sequence<mutable_buffer, const_buffer>
0206 : true_type
0207 {
0208 };
0209
0210 template <>
0211 struct is_buffer_sequence<const_buffer, const_buffer>
0212 : true_type
0213 {
0214 };
0215
0216 template <>
0217 struct is_buffer_sequence<const_buffer, mutable_buffer>
0218 : false_type
0219 {
0220 };
0221
0222 template <>
0223 struct is_buffer_sequence<mutable_registered_buffer, mutable_buffer>
0224 : true_type
0225 {
0226 };
0227
0228 template <>
0229 struct is_buffer_sequence<mutable_registered_buffer, const_buffer>
0230 : true_type
0231 {
0232 };
0233
0234 template <>
0235 struct is_buffer_sequence<const_registered_buffer, const_buffer>
0236 : true_type
0237 {
0238 };
0239
0240 template <>
0241 struct is_buffer_sequence<const_registered_buffer, mutable_buffer>
0242 : false_type
0243 {
0244 };
0245
0246 template <typename T>
0247 struct is_dynamic_buffer_class_v1
0248 : integral_constant<bool,
0249 sizeof(size_memfn_helper<T>(0)) != 1 &&
0250 sizeof(max_size_memfn_helper<T>(0)) != 1 &&
0251 sizeof(capacity_memfn_helper<T>(0)) != 1 &&
0252 sizeof(data_memfn_helper<T>(0)) != 1 &&
0253 sizeof(consume_memfn_helper<T>(0)) != 1 &&
0254 sizeof(prepare_memfn_helper<T>(0)) != 1 &&
0255 sizeof(commit_memfn_helper<T>(0)) != 1 &&
0256 sizeof(const_buffers_type_typedef_helper<T>(0)) == 1 &&
0257 sizeof(mutable_buffers_type_typedef_helper<T>(0)) == 1>
0258 {
0259 };
0260
0261 template <typename T>
0262 struct is_dynamic_buffer_v1
0263 : conditional<is_class<T>::value,
0264 is_dynamic_buffer_class_v1<T>,
0265 false_type>::type
0266 {
0267 };
0268
0269 template <typename T>
0270 struct is_dynamic_buffer_class_v2
0271 : integral_constant<bool,
0272 sizeof(size_memfn_helper<T>(0)) != 1 &&
0273 sizeof(max_size_memfn_helper<T>(0)) != 1 &&
0274 sizeof(capacity_memfn_helper<T>(0)) != 1 &&
0275 sizeof(data_memfn_helper<T>(0)) != 1 &&
0276 sizeof(consume_memfn_helper<T>(0)) != 1 &&
0277 sizeof(grow_memfn_helper<T>(0)) != 1 &&
0278 sizeof(shrink_memfn_helper<T>(0)) != 1 &&
0279 sizeof(const_buffers_type_typedef_helper<T>(0)) == 1 &&
0280 sizeof(mutable_buffers_type_typedef_helper<T>(0)) == 1>
0281 {
0282 };
0283
0284 template <typename T>
0285 struct is_dynamic_buffer_v2
0286 : conditional<is_class<T>::value,
0287 is_dynamic_buffer_class_v2<T>,
0288 false_type>::type
0289 {
0290 };
0291
0292 }
0293 }
0294 }
0295
0296 #include <boost/asio/detail/pop_options.hpp>
0297
0298 #endif