is_array_common.hpp 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248
  1. // (C) Copyright Edward Diener 2011-2015
  2. // Use, modification and distribution are subject to the Boost Software License,
  3. // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
  4. // http://www.boost.org/LICENSE_1_0.txt).
  5. #if !defined(BOOST_VMD_DETAIL_IS_ARRAY_COMMON_HPP)
  6. #define BOOST_VMD_DETAIL_IS_ARRAY_COMMON_HPP
  7. #include <boost/preprocessor/cat.hpp>
  8. #include <boost/preprocessor/comparison/equal.hpp>
  9. #include <boost/preprocessor/control/if.hpp>
  10. #include <boost/preprocessor/control/iif.hpp>
  11. #include <boost/preprocessor/facilities/empty.hpp>
  12. #include <boost/preprocessor/tuple/elem.hpp>
  13. #include <boost/preprocessor/tuple/size.hpp>
  14. #include <boost/vmd/identity.hpp>
  15. #include <boost/vmd/is_empty.hpp>
  16. #include <boost/vmd/is_number.hpp>
  17. #include <boost/vmd/is_tuple.hpp>
  18. #include <boost/vmd/detail/is_empty_tuple.hpp>
  19. #define BOOST_VMD_DETAIL_IS_ARRAY_SYNTAX(tuple) \
  20. BOOST_VMD_IDENTITY_RESULT \
  21. ( \
  22. BOOST_PP_IIF \
  23. ( \
  24. BOOST_PP_EQUAL(2,BOOST_PP_TUPLE_SIZE(tuple)), \
  25. BOOST_VMD_DETAIL_IS_ARRAY_CHECK_ARRAY_FORM, \
  26. BOOST_VMD_IDENTITY(0) \
  27. ) \
  28. (tuple) \
  29. ) \
  30. /**/
  31. #define BOOST_VMD_DETAIL_IS_ARRAY_SYNTAX_D(d,tuple) \
  32. BOOST_VMD_IDENTITY_RESULT \
  33. ( \
  34. BOOST_PP_IIF \
  35. ( \
  36. BOOST_PP_EQUAL_D(d,2,BOOST_PP_TUPLE_SIZE(tuple)), \
  37. BOOST_VMD_DETAIL_IS_ARRAY_CHECK_ARRAY_FORM_D, \
  38. BOOST_VMD_IDENTITY(0) \
  39. ) \
  40. (d,tuple) \
  41. ) \
  42. /**/
  43. /*
  44. Check if the first element of the tuple is equal to the number of tuple elements of the second element
  45. */
  46. #define BOOST_VMD_DETAIL_IS_ARRAY_CHECK_NUMERIC_MATCH_SIZE(x) \
  47. BOOST_PP_EQUAL(BOOST_PP_TUPLE_ELEM(0,x),BOOST_PP_TUPLE_SIZE(BOOST_PP_TUPLE_ELEM(1,x))) \
  48. /**/
  49. #define BOOST_VMD_DETAIL_IS_ARRAY_CHECK_NUMERIC_MATCH_SIZE_D(d,x) \
  50. BOOST_PP_EQUAL_D(d,BOOST_PP_TUPLE_ELEM(0,x),BOOST_PP_TUPLE_SIZE(BOOST_PP_TUPLE_ELEM(1,x))) \
  51. /**/
  52. #define BOOST_VMD_DETAIL_IS_ARRAY_CHECK_EMPTY(tuple) \
  53. BOOST_VMD_DETAIL_IS_EMPTY_TUPLE_SIZE(BOOST_PP_TUPLE_ELEM(1,tuple)) \
  54. /**/
  55. #define BOOST_VMD_DETAIL_IS_ARRAY_CHECK_EMPTY_D(d,tuple) \
  56. BOOST_VMD_DETAIL_IS_EMPTY_TUPLE_SIZE(BOOST_PP_TUPLE_ELEM(1,tuple)) \
  57. /**/
  58. #define BOOST_VMD_DETAIL_IS_ARRAY_CHECK_NUMERIC_MATCH(tuple) \
  59. BOOST_PP_IF \
  60. ( \
  61. BOOST_PP_TUPLE_ELEM(0,tuple), \
  62. BOOST_VMD_DETAIL_IS_ARRAY_CHECK_NUMERIC_MATCH_SIZE, \
  63. BOOST_VMD_DETAIL_IS_ARRAY_CHECK_EMPTY \
  64. ) \
  65. (tuple) \
  66. /**/
  67. #define BOOST_VMD_DETAIL_IS_ARRAY_CHECK_NUMERIC_MATCH_D(d,tuple) \
  68. BOOST_PP_IF \
  69. ( \
  70. BOOST_PP_TUPLE_ELEM(0,tuple), \
  71. BOOST_VMD_DETAIL_IS_ARRAY_CHECK_NUMERIC_MATCH_SIZE_D, \
  72. BOOST_VMD_DETAIL_IS_ARRAY_CHECK_EMPTY_D \
  73. ) \
  74. (d,tuple) \
  75. /**/
  76. /*
  77. Check if the first element is numeric
  78. */
  79. #define BOOST_VMD_DETAIL_IS_ARRAY_CHECK_NUMERIC(tuple) \
  80. BOOST_VMD_IDENTITY_RESULT \
  81. ( \
  82. BOOST_PP_IIF \
  83. ( \
  84. BOOST_VMD_DETAIL_IS_ARRAY_NUM(BOOST_PP_TUPLE_ELEM(0,tuple)), \
  85. BOOST_VMD_DETAIL_IS_ARRAY_CHECK_NUMERIC_MATCH, \
  86. BOOST_VMD_IDENTITY(0) \
  87. ) \
  88. (tuple) \
  89. ) \
  90. /**/
  91. #define BOOST_VMD_DETAIL_IS_ARRAY_CHECK_NUMERIC_D(d,tuple) \
  92. BOOST_VMD_IDENTITY_RESULT \
  93. ( \
  94. BOOST_PP_IIF \
  95. ( \
  96. BOOST_VMD_DETAIL_IS_ARRAY_NUM(BOOST_PP_TUPLE_ELEM(0,tuple)), \
  97. BOOST_VMD_DETAIL_IS_ARRAY_CHECK_NUMERIC_MATCH_D, \
  98. BOOST_VMD_IDENTITY(0) \
  99. ) \
  100. (d,tuple) \
  101. ) \
  102. /**/
  103. #define BOOST_VMD_DETAIL_IS_ARRAY_CHECK_NUMBER(tuple) \
  104. BOOST_VMD_IDENTITY_RESULT \
  105. ( \
  106. BOOST_PP_IIF \
  107. ( \
  108. BOOST_VMD_IS_NUMBER(BOOST_PP_TUPLE_ELEM(0,tuple)), \
  109. BOOST_VMD_DETAIL_IS_ARRAY_CHECK_NUMERIC, \
  110. BOOST_VMD_IDENTITY(0) \
  111. ) \
  112. (tuple) \
  113. ) \
  114. /**/
  115. #define BOOST_VMD_DETAIL_IS_ARRAY_CHECK_NUMBER_D(d,tuple) \
  116. BOOST_VMD_IDENTITY_RESULT \
  117. ( \
  118. BOOST_PP_IIF \
  119. ( \
  120. BOOST_VMD_IS_NUMBER(BOOST_PP_TUPLE_ELEM(0,tuple)), \
  121. BOOST_VMD_DETAIL_IS_ARRAY_CHECK_NUMERIC_D, \
  122. BOOST_VMD_IDENTITY(0) \
  123. ) \
  124. (d,tuple) \
  125. ) \
  126. /**/
  127. /*
  128. Check if the second element is a tuple
  129. */
  130. #define BOOST_VMD_DETAIL_IS_ARRAY_CHECK_ARRAY_FORM(tuple) \
  131. BOOST_VMD_IDENTITY_RESULT \
  132. ( \
  133. BOOST_PP_IIF \
  134. ( \
  135. BOOST_VMD_IS_TUPLE(BOOST_PP_TUPLE_ELEM(1,tuple)), \
  136. BOOST_VMD_DETAIL_IS_ARRAY_CHECK_NUMBER, \
  137. BOOST_VMD_IDENTITY(0) \
  138. ) \
  139. (tuple) \
  140. ) \
  141. /**/
  142. #define BOOST_VMD_DETAIL_IS_ARRAY_CHECK_ARRAY_FORM_D(d,tuple) \
  143. BOOST_VMD_IDENTITY_RESULT \
  144. ( \
  145. BOOST_PP_IIF \
  146. ( \
  147. BOOST_VMD_IS_TUPLE(BOOST_PP_TUPLE_ELEM(1,tuple)), \
  148. BOOST_VMD_DETAIL_IS_ARRAY_CHECK_NUMBER_D, \
  149. BOOST_VMD_IDENTITY(0) \
  150. ) \
  151. (d,tuple) \
  152. ) \
  153. /**/
  154. #define BOOST_VMD_DETAIL_IS_ARRAY_NUM(x) BOOST_VMD_IS_EMPTY(BOOST_PP_CAT(BOOST_VMD_DETAIL_IS_ARRAY_NUM_HELPER_, x) BOOST_PP_EMPTY())
  155. #define BOOST_VMD_DETAIL_IS_ARRAY_NUM_HELPER_0
  156. #define BOOST_VMD_DETAIL_IS_ARRAY_NUM_HELPER_1
  157. #define BOOST_VMD_DETAIL_IS_ARRAY_NUM_HELPER_2
  158. #define BOOST_VMD_DETAIL_IS_ARRAY_NUM_HELPER_3
  159. #define BOOST_VMD_DETAIL_IS_ARRAY_NUM_HELPER_4
  160. #define BOOST_VMD_DETAIL_IS_ARRAY_NUM_HELPER_5
  161. #define BOOST_VMD_DETAIL_IS_ARRAY_NUM_HELPER_6
  162. #define BOOST_VMD_DETAIL_IS_ARRAY_NUM_HELPER_7
  163. #define BOOST_VMD_DETAIL_IS_ARRAY_NUM_HELPER_8
  164. #define BOOST_VMD_DETAIL_IS_ARRAY_NUM_HELPER_9
  165. #define BOOST_VMD_DETAIL_IS_ARRAY_NUM_HELPER_10
  166. #define BOOST_VMD_DETAIL_IS_ARRAY_NUM_HELPER_11
  167. #define BOOST_VMD_DETAIL_IS_ARRAY_NUM_HELPER_12
  168. #define BOOST_VMD_DETAIL_IS_ARRAY_NUM_HELPER_13
  169. #define BOOST_VMD_DETAIL_IS_ARRAY_NUM_HELPER_14
  170. #define BOOST_VMD_DETAIL_IS_ARRAY_NUM_HELPER_15
  171. #define BOOST_VMD_DETAIL_IS_ARRAY_NUM_HELPER_16
  172. #define BOOST_VMD_DETAIL_IS_ARRAY_NUM_HELPER_17
  173. #define BOOST_VMD_DETAIL_IS_ARRAY_NUM_HELPER_18
  174. #define BOOST_VMD_DETAIL_IS_ARRAY_NUM_HELPER_19
  175. #define BOOST_VMD_DETAIL_IS_ARRAY_NUM_HELPER_20
  176. #define BOOST_VMD_DETAIL_IS_ARRAY_NUM_HELPER_21
  177. #define BOOST_VMD_DETAIL_IS_ARRAY_NUM_HELPER_22
  178. #define BOOST_VMD_DETAIL_IS_ARRAY_NUM_HELPER_23
  179. #define BOOST_VMD_DETAIL_IS_ARRAY_NUM_HELPER_24
  180. #define BOOST_VMD_DETAIL_IS_ARRAY_NUM_HELPER_25
  181. #define BOOST_VMD_DETAIL_IS_ARRAY_NUM_HELPER_26
  182. #define BOOST_VMD_DETAIL_IS_ARRAY_NUM_HELPER_27
  183. #define BOOST_VMD_DETAIL_IS_ARRAY_NUM_HELPER_28
  184. #define BOOST_VMD_DETAIL_IS_ARRAY_NUM_HELPER_29
  185. #define BOOST_VMD_DETAIL_IS_ARRAY_NUM_HELPER_30
  186. #define BOOST_VMD_DETAIL_IS_ARRAY_NUM_HELPER_31
  187. #define BOOST_VMD_DETAIL_IS_ARRAY_NUM_HELPER_32
  188. #define BOOST_VMD_DETAIL_IS_ARRAY_NUM_HELPER_33
  189. #define BOOST_VMD_DETAIL_IS_ARRAY_NUM_HELPER_34
  190. #define BOOST_VMD_DETAIL_IS_ARRAY_NUM_HELPER_35
  191. #define BOOST_VMD_DETAIL_IS_ARRAY_NUM_HELPER_36
  192. #define BOOST_VMD_DETAIL_IS_ARRAY_NUM_HELPER_37
  193. #define BOOST_VMD_DETAIL_IS_ARRAY_NUM_HELPER_38
  194. #define BOOST_VMD_DETAIL_IS_ARRAY_NUM_HELPER_39
  195. #define BOOST_VMD_DETAIL_IS_ARRAY_NUM_HELPER_40
  196. #define BOOST_VMD_DETAIL_IS_ARRAY_NUM_HELPER_41
  197. #define BOOST_VMD_DETAIL_IS_ARRAY_NUM_HELPER_42
  198. #define BOOST_VMD_DETAIL_IS_ARRAY_NUM_HELPER_43
  199. #define BOOST_VMD_DETAIL_IS_ARRAY_NUM_HELPER_44
  200. #define BOOST_VMD_DETAIL_IS_ARRAY_NUM_HELPER_45
  201. #define BOOST_VMD_DETAIL_IS_ARRAY_NUM_HELPER_46
  202. #define BOOST_VMD_DETAIL_IS_ARRAY_NUM_HELPER_47
  203. #define BOOST_VMD_DETAIL_IS_ARRAY_NUM_HELPER_48
  204. #define BOOST_VMD_DETAIL_IS_ARRAY_NUM_HELPER_49
  205. #define BOOST_VMD_DETAIL_IS_ARRAY_NUM_HELPER_50
  206. #define BOOST_VMD_DETAIL_IS_ARRAY_NUM_HELPER_51
  207. #define BOOST_VMD_DETAIL_IS_ARRAY_NUM_HELPER_52
  208. #define BOOST_VMD_DETAIL_IS_ARRAY_NUM_HELPER_53
  209. #define BOOST_VMD_DETAIL_IS_ARRAY_NUM_HELPER_54
  210. #define BOOST_VMD_DETAIL_IS_ARRAY_NUM_HELPER_55
  211. #define BOOST_VMD_DETAIL_IS_ARRAY_NUM_HELPER_56
  212. #define BOOST_VMD_DETAIL_IS_ARRAY_NUM_HELPER_57
  213. #define BOOST_VMD_DETAIL_IS_ARRAY_NUM_HELPER_58
  214. #define BOOST_VMD_DETAIL_IS_ARRAY_NUM_HELPER_59
  215. #define BOOST_VMD_DETAIL_IS_ARRAY_NUM_HELPER_60
  216. #define BOOST_VMD_DETAIL_IS_ARRAY_NUM_HELPER_61
  217. #define BOOST_VMD_DETAIL_IS_ARRAY_NUM_HELPER_62
  218. #define BOOST_VMD_DETAIL_IS_ARRAY_NUM_HELPER_63
  219. #define BOOST_VMD_DETAIL_IS_ARRAY_NUM_HELPER_64
  220. #endif /* BOOST_VMD_DETAIL_IS_ARRAY_COMMON_HPP */