Audio plugin host https://kx.studio/carla
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

200 lines
5.0KB

  1. //
  2. // detail/is_buffer_sequence.hpp
  3. // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  4. //
  5. // Copyright (c) 2003-2015 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. #ifndef ASIO_DETAIL_IS_BUFFER_SEQUENCE_HPP
  11. #define ASIO_DETAIL_IS_BUFFER_SEQUENCE_HPP
  12. #if defined(_MSC_VER) && (_MSC_VER >= 1200)
  13. # pragma once
  14. #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
  15. #include "asio/detail/config.hpp"
  16. #include "asio/detail/type_traits.hpp"
  17. #include "asio/detail/push_options.hpp"
  18. namespace asio {
  19. namespace detail {
  20. struct buffer_sequence_memfns_base
  21. {
  22. void begin();
  23. void end();
  24. void size();
  25. void max_size();
  26. void capacity();
  27. void data();
  28. void prepare();
  29. void commit();
  30. void consume();
  31. };
  32. template <typename T>
  33. struct buffer_sequence_memfns_derived
  34. : T, buffer_sequence_memfns_base
  35. {
  36. };
  37. template <typename T, T>
  38. struct buffer_sequence_memfns_check
  39. {
  40. };
  41. template <typename>
  42. char (&begin_memfn_helper(...))[2];
  43. template <typename T>
  44. char begin_memfn_helper(
  45. buffer_sequence_memfns_check<
  46. void (buffer_sequence_memfns_base::*)(),
  47. &buffer_sequence_memfns_derived<T>::begin>*);
  48. template <typename>
  49. char (&end_memfn_helper(...))[2];
  50. template <typename T>
  51. char end_memfn_helper(
  52. buffer_sequence_memfns_check<
  53. void (buffer_sequence_memfns_base::*)(),
  54. &buffer_sequence_memfns_derived<T>::end>*);
  55. template <typename>
  56. char (&size_memfn_helper(...))[2];
  57. template <typename T>
  58. char size_memfn_helper(
  59. buffer_sequence_memfns_check<
  60. void (buffer_sequence_memfns_base::*)(),
  61. &buffer_sequence_memfns_derived<T>::size>*);
  62. template <typename>
  63. char (&max_size_memfn_helper(...))[2];
  64. template <typename T>
  65. char max_size_memfn_helper(
  66. buffer_sequence_memfns_check<
  67. void (buffer_sequence_memfns_base::*)(),
  68. &buffer_sequence_memfns_derived<T>::max_size>*);
  69. template <typename>
  70. char (&capacity_memfn_helper(...))[2];
  71. template <typename T>
  72. char capacity_memfn_helper(
  73. buffer_sequence_memfns_check<
  74. void (buffer_sequence_memfns_base::*)(),
  75. &buffer_sequence_memfns_derived<T>::capacity>*);
  76. template <typename>
  77. char (&data_memfn_helper(...))[2];
  78. template <typename T>
  79. char data_memfn_helper(
  80. buffer_sequence_memfns_check<
  81. void (buffer_sequence_memfns_base::*)(),
  82. &buffer_sequence_memfns_derived<T>::data>*);
  83. template <typename>
  84. char (&prepare_memfn_helper(...))[2];
  85. template <typename T>
  86. char prepare_memfn_helper(
  87. buffer_sequence_memfns_check<
  88. void (buffer_sequence_memfns_base::*)(),
  89. &buffer_sequence_memfns_derived<T>::data>*);
  90. template <typename>
  91. char (&commit_memfn_helper(...))[2];
  92. template <typename T>
  93. char commit_memfn_helper(
  94. buffer_sequence_memfns_check<
  95. void (buffer_sequence_memfns_base::*)(),
  96. &buffer_sequence_memfns_derived<T>::commit>*);
  97. template <typename>
  98. char (&consume_memfn_helper(...))[2];
  99. template <typename T>
  100. char consume_memfn_helper(
  101. buffer_sequence_memfns_check<
  102. void (buffer_sequence_memfns_base::*)(),
  103. &buffer_sequence_memfns_derived<T>::consume>*);
  104. template <typename, typename>
  105. char (&value_type_const_iterator_typedefs_helper(...))[2];
  106. template <typename T, typename Buffer>
  107. char value_type_const_iterator_typedefs_helper(
  108. typename T::const_iterator*,
  109. typename enable_if<is_convertible<
  110. typename T::value_type, Buffer>::value>::type*);
  111. template <typename>
  112. char (&const_buffers_type_typedef_helper(...))[2];
  113. template <typename T>
  114. char const_buffers_type_typedef_helper(
  115. typename T::const_buffers_type*);
  116. template <typename>
  117. char (&mutable_buffers_type_typedef_helper(...))[2];
  118. template <typename T>
  119. char mutable_buffers_type_typedef_helper(
  120. typename T::mutable_buffers_type*);
  121. template <typename T, typename Buffer>
  122. struct is_buffer_sequence_class
  123. : integral_constant<bool,
  124. sizeof(begin_memfn_helper<T>(0)) != 1 &&
  125. sizeof(end_memfn_helper<T>(0)) != 1 &&
  126. sizeof(value_type_const_iterator_typedefs_helper<T, Buffer>(0, 0)) == 1>
  127. {
  128. };
  129. template <typename T, typename Buffer>
  130. struct is_buffer_sequence
  131. : conditional<is_class<T>::value,
  132. is_buffer_sequence_class<T, Buffer>,
  133. false_type>::type
  134. {
  135. };
  136. template <typename T>
  137. struct is_dynamic_buffer_sequence_class
  138. : integral_constant<bool,
  139. sizeof(size_memfn_helper<T>(0)) != 1 &&
  140. sizeof(max_size_memfn_helper<T>(0)) != 1 &&
  141. sizeof(capacity_memfn_helper<T>(0)) != 1 &&
  142. sizeof(data_memfn_helper<T>(0)) != 1 &&
  143. sizeof(consume_memfn_helper<T>(0)) != 1 &&
  144. sizeof(prepare_memfn_helper<T>(0)) != 1 &&
  145. sizeof(commit_memfn_helper<T>(0)) != 1 &&
  146. sizeof(const_buffers_type_typedef_helper<T>(0)) == 1 &&
  147. sizeof(mutable_buffers_type_typedef_helper<T>(0)) == 1>
  148. {
  149. };
  150. template <typename T>
  151. struct is_dynamic_buffer_sequence
  152. : conditional<is_class<T>::value,
  153. is_dynamic_buffer_sequence_class<T>,
  154. false_type>::type
  155. {
  156. };
  157. } // namespace detail
  158. } // namespace asio
  159. #include "asio/detail/pop_options.hpp"
  160. #endif // ASIO_DETAIL_IS_BUFFER_SEQUENCE_HPP