tuple.hpp 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196
  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_TUPLE_HPP)
  6. #define BOOST_VMD_DETAIL_TUPLE_HPP
  7. #include <boost/preprocessor/comparison/equal.hpp>
  8. #include <boost/preprocessor/control/iif.hpp>
  9. #include <boost/preprocessor/punctuation/is_begin_parens.hpp>
  10. #include <boost/preprocessor/tuple/size.hpp>
  11. #include <boost/preprocessor/variadic/elem.hpp>
  12. #include <boost/vmd/empty.hpp>
  13. #include <boost/vmd/is_empty.hpp>
  14. #include <boost/vmd/identity.hpp>
  15. #include <boost/vmd/detail/empty_result.hpp>
  16. #include <boost/vmd/detail/mods.hpp>
  17. #include <boost/vmd/detail/parens.hpp>
  18. #define BOOST_VMD_DETAIL_TUPLE_BST_CS(vseq) \
  19. BOOST_PP_EQUAL(BOOST_PP_TUPLE_SIZE(BOOST_VMD_DETAIL_BEGIN_PARENS(vseq)),1) \
  20. /**/
  21. #define BOOST_VMD_DETAIL_TUPLE_BST_CS_D(d,vseq) \
  22. BOOST_PP_EQUAL_D(d,BOOST_PP_TUPLE_SIZE(BOOST_VMD_DETAIL_BEGIN_PARENS(vseq)),1) \
  23. /**/
  24. #define BOOST_VMD_DETAIL_TUPLE_BST(vseq) \
  25. BOOST_VMD_IDENTITY_RESULT \
  26. ( \
  27. BOOST_PP_IIF \
  28. ( \
  29. BOOST_PP_IS_BEGIN_PARENS(vseq), \
  30. BOOST_VMD_DETAIL_TUPLE_BST_CS, \
  31. BOOST_VMD_IDENTITY(0) \
  32. ) \
  33. (vseq) \
  34. ) \
  35. /**/
  36. #define BOOST_VMD_DETAIL_TUPLE_BST_D(d,vseq) \
  37. BOOST_VMD_IDENTITY_RESULT \
  38. ( \
  39. BOOST_PP_IIF \
  40. ( \
  41. BOOST_PP_IS_BEGIN_PARENS(vseq), \
  42. BOOST_VMD_DETAIL_TUPLE_BST_CS_D, \
  43. BOOST_VMD_IDENTITY(0) \
  44. ) \
  45. (d,vseq) \
  46. ) \
  47. /**/
  48. #define BOOST_VMD_DETAIL_TUPLE_BSEQ_NXT(vseq) \
  49. BOOST_VMD_DETAIL_TUPLE_BST(BOOST_VMD_DETAIL_AFTER_PARENS_DATA(vseq)) \
  50. /**/
  51. #define BOOST_VMD_DETAIL_TUPLE_BSEQ_NXT_D(d,vseq) \
  52. BOOST_VMD_DETAIL_TUPLE_BST_D(d,BOOST_VMD_DETAIL_AFTER_PARENS_DATA(vseq)) \
  53. /**/
  54. #define BOOST_VMD_DETAIL_TUPLE_BSEQ(vseq) \
  55. BOOST_VMD_IDENTITY_RESULT \
  56. ( \
  57. BOOST_PP_IIF \
  58. ( \
  59. BOOST_VMD_DETAIL_TUPLE_BST(vseq), \
  60. BOOST_VMD_DETAIL_TUPLE_BSEQ_NXT, \
  61. BOOST_VMD_IDENTITY(0) \
  62. ) \
  63. (vseq) \
  64. ) \
  65. /**/
  66. #define BOOST_VMD_DETAIL_TUPLE_BSEQ_D(d,vseq) \
  67. BOOST_VMD_IDENTITY_RESULT \
  68. ( \
  69. BOOST_PP_IIF \
  70. ( \
  71. BOOST_VMD_DETAIL_TUPLE_BST_D(d,vseq), \
  72. BOOST_VMD_DETAIL_TUPLE_BSEQ_NXT_D, \
  73. BOOST_VMD_IDENTITY(0) \
  74. ) \
  75. (d,vseq) \
  76. ) \
  77. /**/
  78. #define BOOST_VMD_DETAIL_TUPLE_SPLIT_CHK_SEQ(vseq) \
  79. BOOST_PP_IIF \
  80. ( \
  81. BOOST_VMD_DETAIL_TUPLE_BSEQ(vseq), \
  82. BOOST_VMD_DETAIL_EMPTY_RESULT, \
  83. BOOST_VMD_DETAIL_SPLIT_PARENS \
  84. ) \
  85. (vseq) \
  86. /**/
  87. #define BOOST_VMD_DETAIL_TUPLE_SPLIT_CHK_SEQ_D(d,vseq) \
  88. BOOST_PP_IIF \
  89. ( \
  90. BOOST_VMD_DETAIL_TUPLE_BSEQ_D(d,vseq), \
  91. BOOST_VMD_DETAIL_EMPTY_RESULT, \
  92. BOOST_VMD_DETAIL_SPLIT_PARENS \
  93. ) \
  94. (vseq) \
  95. /**/
  96. #define BOOST_VMD_DETAIL_TUPLE_SPLIT(vseq) \
  97. BOOST_PP_IIF \
  98. ( \
  99. BOOST_PP_IS_BEGIN_PARENS(vseq), \
  100. BOOST_VMD_DETAIL_TUPLE_SPLIT_CHK_SEQ, \
  101. BOOST_VMD_DETAIL_EMPTY_RESULT \
  102. ) \
  103. (vseq) \
  104. /**/
  105. #define BOOST_VMD_DETAIL_TUPLE_SPLIT_D(d,vseq) \
  106. BOOST_PP_IIF \
  107. ( \
  108. BOOST_PP_IS_BEGIN_PARENS(vseq), \
  109. BOOST_VMD_DETAIL_TUPLE_SPLIT_CHK_SEQ_D, \
  110. BOOST_VMD_DETAIL_EMPTY_RESULT \
  111. ) \
  112. (d,vseq) \
  113. /**/
  114. #define BOOST_VMD_DETAIL_TUPLE_PROCESS_CHK_SEQ(vseq) \
  115. BOOST_PP_IIF \
  116. ( \
  117. BOOST_VMD_DETAIL_TUPLE_BSEQ(vseq), \
  118. BOOST_VMD_EMPTY, \
  119. BOOST_VMD_DETAIL_BEGIN_PARENS \
  120. ) \
  121. (vseq) \
  122. /**/
  123. #define BOOST_VMD_DETAIL_TUPLE_PROCESS_CHK_SEQ_D(d,vseq) \
  124. BOOST_PP_IIF \
  125. ( \
  126. BOOST_VMD_DETAIL_TUPLE_BSEQ_D(d,vseq), \
  127. BOOST_VMD_EMPTY, \
  128. BOOST_VMD_DETAIL_BEGIN_PARENS \
  129. ) \
  130. (vseq) \
  131. /**/
  132. #define BOOST_VMD_DETAIL_TUPLE_PROCESS(vseq) \
  133. BOOST_PP_IIF \
  134. ( \
  135. BOOST_PP_IS_BEGIN_PARENS(vseq), \
  136. BOOST_VMD_DETAIL_TUPLE_PROCESS_CHK_SEQ, \
  137. BOOST_VMD_EMPTY \
  138. ) \
  139. (vseq) \
  140. /**/
  141. #define BOOST_VMD_DETAIL_TUPLE_PROCESS_D(d,vseq) \
  142. BOOST_PP_IIF \
  143. ( \
  144. BOOST_PP_IS_BEGIN_PARENS(vseq), \
  145. BOOST_VMD_DETAIL_TUPLE_PROCESS_CHK_SEQ_D, \
  146. BOOST_VMD_EMPTY \
  147. ) \
  148. (d,vseq) \
  149. /**/
  150. #define BOOST_VMD_DETAIL_TUPLE(...) \
  151. BOOST_PP_IIF \
  152. ( \
  153. BOOST_VMD_DETAIL_MODS_IS_RESULT_AFTER \
  154. ( \
  155. BOOST_VMD_DETAIL_NEW_MODS(BOOST_VMD_ALLOW_AFTER,__VA_ARGS__) \
  156. ), \
  157. BOOST_VMD_DETAIL_TUPLE_SPLIT, \
  158. BOOST_VMD_DETAIL_TUPLE_PROCESS \
  159. ) \
  160. (BOOST_PP_VARIADIC_ELEM(0,__VA_ARGS__)) \
  161. /**/
  162. #define BOOST_VMD_DETAIL_TUPLE_D(d,...) \
  163. BOOST_PP_IIF \
  164. ( \
  165. BOOST_VMD_DETAIL_MODS_IS_RESULT_AFTER \
  166. ( \
  167. BOOST_VMD_DETAIL_NEW_MODS(BOOST_VMD_ALLOW_AFTER,__VA_ARGS__) \
  168. ), \
  169. BOOST_VMD_DETAIL_TUPLE_SPLIT_D, \
  170. BOOST_VMD_DETAIL_TUPLE_PROCESS_D \
  171. ) \
  172. (d,BOOST_PP_VARIADIC_ELEM(0,__VA_ARGS__)) \
  173. /**/
  174. #endif /* BOOST_VMD_DETAIL_TUPLE_HPP */