array.hpp 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  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_ARRAY_HPP)
  6. #define BOOST_VMD_DETAIL_ARRAY_HPP
  7. #include <boost/preprocessor/control/expr_iif.hpp>
  8. #include <boost/preprocessor/control/iif.hpp>
  9. #include <boost/preprocessor/tuple/elem.hpp>
  10. #include <boost/preprocessor/variadic/elem.hpp>
  11. #include <boost/vmd/empty.hpp>
  12. #include <boost/vmd/identity.hpp>
  13. #include <boost/vmd/is_empty.hpp>
  14. #include <boost/vmd/detail/empty_result.hpp>
  15. #include <boost/vmd/detail/is_array_common.hpp>
  16. #include <boost/vmd/detail/mods.hpp>
  17. #include <boost/vmd/detail/tuple.hpp>
  18. #define BOOST_VMD_DETAIL_ARRAY_CHECK_FOR_ARRAY(tuple) \
  19. BOOST_VMD_IDENTITY_RESULT \
  20. ( \
  21. BOOST_PP_IIF \
  22. ( \
  23. BOOST_VMD_DETAIL_IS_ARRAY_SYNTAX \
  24. ( \
  25. BOOST_PP_TUPLE_ELEM \
  26. ( \
  27. 0, \
  28. tuple \
  29. ) \
  30. ), \
  31. BOOST_VMD_IDENTITY(tuple), \
  32. BOOST_VMD_DETAIL_EMPTY_RESULT \
  33. ) \
  34. (tuple) \
  35. ) \
  36. /**/
  37. #define BOOST_VMD_DETAIL_ARRAY_CHECK_FOR_ARRAY_D(d,tuple) \
  38. BOOST_VMD_IDENTITY_RESULT \
  39. ( \
  40. BOOST_PP_IIF \
  41. ( \
  42. BOOST_VMD_DETAIL_IS_ARRAY_SYNTAX_D \
  43. ( \
  44. d, \
  45. BOOST_PP_TUPLE_ELEM \
  46. ( \
  47. 0, \
  48. tuple \
  49. ) \
  50. ), \
  51. BOOST_VMD_IDENTITY(tuple), \
  52. BOOST_VMD_DETAIL_EMPTY_RESULT \
  53. ) \
  54. (tuple) \
  55. ) \
  56. /**/
  57. #define BOOST_VMD_DETAIL_ARRAY_PROCESS(tuple) \
  58. BOOST_PP_IIF \
  59. ( \
  60. BOOST_VMD_IS_EMPTY \
  61. ( \
  62. BOOST_PP_TUPLE_ELEM \
  63. ( \
  64. 0, \
  65. tuple \
  66. ) \
  67. ), \
  68. BOOST_VMD_DETAIL_EMPTY_RESULT, \
  69. BOOST_VMD_DETAIL_ARRAY_CHECK_FOR_ARRAY \
  70. ) \
  71. (tuple) \
  72. /**/
  73. #define BOOST_VMD_DETAIL_ARRAY_PROCESS_D(d,tuple) \
  74. BOOST_PP_IIF \
  75. ( \
  76. BOOST_VMD_IS_EMPTY \
  77. ( \
  78. BOOST_PP_TUPLE_ELEM \
  79. ( \
  80. 0, \
  81. tuple \
  82. ) \
  83. ), \
  84. BOOST_VMD_DETAIL_EMPTY_RESULT, \
  85. BOOST_VMD_DETAIL_ARRAY_CHECK_FOR_ARRAY_D \
  86. ) \
  87. (d,tuple) \
  88. /**/
  89. #define BOOST_VMD_DETAIL_ARRAY_SPLIT(param) \
  90. BOOST_VMD_DETAIL_ARRAY_PROCESS \
  91. ( \
  92. BOOST_VMD_DETAIL_TUPLE(param,BOOST_VMD_RETURN_AFTER) \
  93. ) \
  94. /**/
  95. #define BOOST_VMD_DETAIL_ARRAY_SPLIT_D(d,param) \
  96. BOOST_VMD_DETAIL_ARRAY_PROCESS_D \
  97. ( \
  98. d, \
  99. BOOST_VMD_DETAIL_TUPLE_D(d,param,BOOST_VMD_RETURN_AFTER) \
  100. ) \
  101. /**/
  102. #define BOOST_VMD_DETAIL_ARRAY_BEGIN_CHECK_FOR_ARRAY(tuple) \
  103. BOOST_PP_EXPR_IIF \
  104. ( \
  105. BOOST_VMD_DETAIL_IS_ARRAY_SYNTAX(tuple), \
  106. tuple \
  107. ) \
  108. /**/
  109. #define BOOST_VMD_DETAIL_ARRAY_BEGIN_CHECK_FOR_ARRAY_D(d,tuple) \
  110. BOOST_PP_EXPR_IIF \
  111. ( \
  112. BOOST_VMD_DETAIL_IS_ARRAY_SYNTAX_D(d,tuple), \
  113. tuple \
  114. ) \
  115. /**/
  116. #define BOOST_VMD_DETAIL_ARRAY_BEGIN_TUPLE(tuple) \
  117. BOOST_PP_IIF \
  118. ( \
  119. BOOST_VMD_IS_EMPTY(tuple), \
  120. BOOST_VMD_EMPTY, \
  121. BOOST_VMD_DETAIL_ARRAY_BEGIN_CHECK_FOR_ARRAY \
  122. ) \
  123. (tuple) \
  124. /**/
  125. #define BOOST_VMD_DETAIL_ARRAY_BEGIN_TUPLE_D(d,tuple) \
  126. BOOST_PP_IIF \
  127. ( \
  128. BOOST_VMD_IS_EMPTY(tuple), \
  129. BOOST_VMD_EMPTY, \
  130. BOOST_VMD_DETAIL_ARRAY_BEGIN_CHECK_FOR_ARRAY_D \
  131. ) \
  132. (d,tuple) \
  133. /**/
  134. #define BOOST_VMD_DETAIL_ARRAY_BEGIN(param) \
  135. BOOST_VMD_DETAIL_ARRAY_BEGIN_TUPLE \
  136. ( \
  137. BOOST_VMD_DETAIL_TUPLE(param) \
  138. ) \
  139. /**/
  140. #define BOOST_VMD_DETAIL_ARRAY_BEGIN_D(d,param) \
  141. BOOST_VMD_DETAIL_ARRAY_BEGIN_TUPLE_D \
  142. ( \
  143. d, \
  144. BOOST_VMD_DETAIL_TUPLE_D(d,param) \
  145. ) \
  146. /**/
  147. #define BOOST_VMD_DETAIL_ARRAY(...) \
  148. BOOST_PP_IIF \
  149. ( \
  150. BOOST_VMD_DETAIL_MODS_IS_RESULT_AFTER \
  151. ( \
  152. BOOST_VMD_DETAIL_NEW_MODS(BOOST_VMD_ALLOW_AFTER,__VA_ARGS__) \
  153. ), \
  154. BOOST_VMD_DETAIL_ARRAY_SPLIT, \
  155. BOOST_VMD_DETAIL_ARRAY_BEGIN \
  156. ) \
  157. (BOOST_PP_VARIADIC_ELEM(0,__VA_ARGS__)) \
  158. /**/
  159. #define BOOST_VMD_DETAIL_ARRAY_D(d,...) \
  160. BOOST_PP_IIF \
  161. ( \
  162. BOOST_VMD_DETAIL_MODS_IS_RESULT_AFTER \
  163. ( \
  164. BOOST_VMD_DETAIL_NEW_MODS(BOOST_VMD_ALLOW_AFTER,__VA_ARGS__) \
  165. ), \
  166. BOOST_VMD_DETAIL_ARRAY_SPLIT_D, \
  167. BOOST_VMD_DETAIL_ARRAY_BEGIN_D \
  168. ) \
  169. (d,BOOST_PP_VARIADIC_ELEM(0,__VA_ARGS__)) \
  170. /**/
  171. #endif /* BOOST_VMD_DETAIL_ARRAY_HPP */