equal_common.hpp 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  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_EQUAL_COMMON_HPP)
  6. #define BOOST_VMD_DETAIL_EQUAL_COMMON_HPP
  7. #include <boost/preprocessor/cat.hpp>
  8. #include <boost/preprocessor/comparison/equal.hpp>
  9. #include <boost/preprocessor/comparison/not_equal.hpp>
  10. #include <boost/preprocessor/control/iif.hpp>
  11. #include <boost/preprocessor/logical/bitand.hpp>
  12. #include <boost/preprocessor/logical/bitor.hpp>
  13. #include <boost/preprocessor/logical/bitxor.hpp>
  14. #include <boost/preprocessor/logical/compl.hpp>
  15. #include <boost/preprocessor/punctuation/is_begin_parens.hpp>
  16. #include <boost/preprocessor/tuple/size.hpp>
  17. #include <boost/vmd/get_type.hpp>
  18. #include <boost/vmd/identity.hpp>
  19. #include <boost/vmd/is_empty.hpp>
  20. #include <boost/vmd/detail/match_single_identifier.hpp>
  21. #include <boost/vmd/detail/equal_type.hpp>
  22. #define BOOST_VMD_DETAIL_EQUAL_CONCAT_1 (1)
  23. #define BOOST_VMD_DETAIL_EQUAL_IS_1(res) \
  24. BOOST_PP_IS_BEGIN_PARENS \
  25. ( \
  26. BOOST_PP_CAT \
  27. ( \
  28. BOOST_VMD_DETAIL_EQUAL_CONCAT_, \
  29. res \
  30. ) \
  31. ) \
  32. /**/
  33. #define BOOST_VMD_DETAIL_EQUAL_MATCH_SINGLE_IDENTIFIER(d,vseq1,vseq2) \
  34. BOOST_VMD_DETAIL_MATCH_SINGLE_IDENTIFIER(vseq1,vseq2) \
  35. /**/
  36. #define BOOST_VMD_DETAIL_EQUAL_CNI_SMP(vseq1,vseq2,vtype) \
  37. BOOST_PP_IIF \
  38. ( \
  39. BOOST_VMD_DETAIL_EQUAL_TYPE(vtype,BOOST_VMD_TYPE_NUMBER), \
  40. BOOST_PP_EQUAL, \
  41. BOOST_PP_IIF \
  42. ( \
  43. BOOST_VMD_DETAIL_EQUAL_TYPE(vtype,BOOST_VMD_TYPE_TYPE), \
  44. BOOST_VMD_DETAIL_EQUAL_TYPE, \
  45. BOOST_VMD_DETAIL_MATCH_SINGLE_IDENTIFIER \
  46. ) \
  47. ) \
  48. (vseq1,vseq2) \
  49. /**/
  50. #define BOOST_VMD_DETAIL_EQUAL_CNI_SMP_D(d,vseq1,vseq2,vtype) \
  51. BOOST_PP_IIF \
  52. ( \
  53. BOOST_VMD_DETAIL_EQUAL_TYPE_D(d,vtype,BOOST_VMD_TYPE_NUMBER), \
  54. BOOST_PP_EQUAL_D, \
  55. BOOST_PP_IIF \
  56. ( \
  57. BOOST_VMD_DETAIL_EQUAL_TYPE_D(d,vtype,BOOST_VMD_TYPE_TYPE), \
  58. BOOST_VMD_DETAIL_EQUAL_TYPE_D, \
  59. BOOST_VMD_DETAIL_EQUAL_MATCH_SINGLE_IDENTIFIER \
  60. ) \
  61. ) \
  62. (d,vseq1,vseq2) \
  63. /**/
  64. #define BOOST_VMD_DETAIL_EQUAL_IS_TUPLE_MISMATCH_SIZE(vseq1,vseq2) \
  65. BOOST_PP_NOT_EQUAL \
  66. ( \
  67. BOOST_PP_TUPLE_SIZE(vseq1), \
  68. BOOST_PP_TUPLE_SIZE(vseq2) \
  69. ) \
  70. /**/
  71. #define BOOST_VMD_DETAIL_EQUAL_IS_TUPLE_MISMATCH_SIZE_D(d,vseq1,vseq2) \
  72. BOOST_PP_NOT_EQUAL_D \
  73. ( \
  74. d, \
  75. BOOST_PP_TUPLE_SIZE(vseq1), \
  76. BOOST_PP_TUPLE_SIZE(vseq2) \
  77. ) \
  78. /**/
  79. #define BOOST_VMD_DETAIL_EQUAL_IS_TUPLE_MISMATCH(vseq1,vseq2,vtype1,vtype2) \
  80. BOOST_VMD_IDENTITY_RESULT \
  81. ( \
  82. BOOST_PP_IIF \
  83. ( \
  84. BOOST_PP_BITAND \
  85. ( \
  86. BOOST_VMD_DETAIL_EQUAL_TYPE(vtype1,BOOST_VMD_TYPE_TUPLE), \
  87. BOOST_VMD_DETAIL_EQUAL_TYPE(vtype2,BOOST_VMD_TYPE_TUPLE) \
  88. ), \
  89. BOOST_VMD_DETAIL_EQUAL_IS_TUPLE_MISMATCH_SIZE, \
  90. BOOST_VMD_IDENTITY(0) \
  91. ) \
  92. (vseq1,vseq2) \
  93. ) \
  94. /**/
  95. #define BOOST_VMD_DETAIL_EQUAL_IS_TUPLE_MISMATCH_D(d,vseq1,vseq2,vtype1,vtype2) \
  96. BOOST_VMD_IDENTITY_RESULT \
  97. ( \
  98. BOOST_PP_IIF \
  99. ( \
  100. BOOST_PP_BITAND \
  101. ( \
  102. BOOST_VMD_DETAIL_EQUAL_TYPE_D(d,vtype1,BOOST_VMD_TYPE_TUPLE), \
  103. BOOST_VMD_DETAIL_EQUAL_TYPE_D(d,vtype2,BOOST_VMD_TYPE_TUPLE) \
  104. ), \
  105. BOOST_VMD_DETAIL_EQUAL_IS_TUPLE_MISMATCH_SIZE_D, \
  106. BOOST_VMD_IDENTITY(0) \
  107. ) \
  108. (d,vseq1,vseq2) \
  109. ) \
  110. /**/
  111. #define BOOST_VMD_DETAIL_EQUAL_BOTH_EMPTY(...) 1
  112. #define BOOST_VMD_DETAIL_EQUAL_CHK_MATCH(bp1,bp2) \
  113. BOOST_PP_COMPL \
  114. ( \
  115. BOOST_PP_BITXOR \
  116. ( \
  117. bp1, \
  118. bp2 \
  119. ) \
  120. ) \
  121. /**/
  122. #define BOOST_VMD_DETAIL_EQUAL_CHK_PARENS_MATCH(vseq1,vseq2) \
  123. BOOST_VMD_DETAIL_EQUAL_CHK_MATCH \
  124. ( \
  125. BOOST_PP_IS_BEGIN_PARENS(vseq1), \
  126. BOOST_PP_IS_BEGIN_PARENS(vseq2) \
  127. ) \
  128. /**/
  129. #define BOOST_VMD_DETAIL_EQUAL_CHK_EMPTY_MATCH(vseq1,vseq2) \
  130. BOOST_VMD_DETAIL_EQUAL_CHK_MATCH \
  131. ( \
  132. BOOST_VMD_IS_EMPTY(vseq1), \
  133. BOOST_VMD_IS_EMPTY(vseq2) \
  134. ) \
  135. /**/
  136. #endif /* BOOST_VMD_DETAIL_EQUAL_COMMON_HPP */