dvm_template_params.hpp 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. // (C) Copyright Edward Diener 2011,2012,2013
  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_TTI_DETAIL_VM_TEMPLATE_PARAMS_HPP)
  6. #define BOOST_TTI_DETAIL_VM_TEMPLATE_PARAMS_HPP
  7. #include <boost/config.hpp>
  8. #include <boost/preprocessor/config/config.hpp>
  9. #if BOOST_PP_VARIADICS
  10. #include <boost/mpl/eval_if.hpp>
  11. #include <boost/mpl/has_xxx.hpp>
  12. #include <boost/mpl/identity.hpp>
  13. #include <boost/preprocessor/arithmetic/add.hpp>
  14. #include <boost/preprocessor/variadic/size.hpp>
  15. #include <boost/preprocessor/cat.hpp>
  16. #include <boost/preprocessor/comparison/equal.hpp>
  17. #include <boost/preprocessor/control/iif.hpp>
  18. #include <boost/preprocessor/detail/is_binary.hpp>
  19. #include <boost/preprocessor/facilities/is_empty.hpp>
  20. #include <boost/preprocessor/seq/enum.hpp>
  21. #include <boost/preprocessor/seq/seq.hpp>
  22. #include <boost/preprocessor/variadic/elem.hpp>
  23. #include <boost/preprocessor/variadic/to_seq.hpp>
  24. #include <boost/tti/detail/dtemplate.hpp>
  25. #include <boost/tti/detail/dtemplate_params.hpp>
  26. #include <boost/tti/detail/denclosing_type.hpp>
  27. #include <boost/tti/gen/namespace_gen.hpp>
  28. #if !defined(BOOST_MPL_CFG_NO_HAS_XXX_TEMPLATE)
  29. #if !BOOST_WORKAROUND(BOOST_MSVC, <= 1400)
  30. #define BOOST_TTI_DETAIL_VM_TRAIT_HAS_TEMPLATE_CHECK_PARAMS(trait,name,...) \
  31. BOOST_TTI_DETAIL_HAS_MEMBER_WITH_FUNCTION_SFINAE \
  32. ( \
  33. ( BOOST_PP_ADD(BOOST_PP_VARIADIC_SIZE(__VA_ARGS__),4), ( trait, name, 1, false, __VA_ARGS__ ) ) \
  34. ) \
  35. /**/
  36. #else // !!BOOST_WORKAROUND(BOOST_MSVC, <= 1400)
  37. #define BOOST_TTI_DETAIL_VM_TRAIT_HAS_TEMPLATE_CHECK_PARAMS(trait,name,...) \
  38. BOOST_TTI_DETAIL_HAS_MEMBER_WITH_TEMPLATE_SFINAE \
  39. ( \
  40. ( BOOST_PP_ADD(BOOST_PP_VARIADIC_SIZE(__VA_ARGS__),4), ( trait, name, 1, false, __VA_ARGS__ ) ) \
  41. ) \
  42. /**/
  43. #endif // !BOOST_WORKAROUND(BOOST_MSVC, <= 1400)
  44. #else // defined(BOOST_MPL_CFG_NO_HAS_XXX_TEMPLATE)
  45. #define BOOST_TTI_DETAIL_VM_TRAIT_HAS_TEMPLATE_CHECK_PARAMS(trait,name,...) \
  46. BOOST_TTI_DETAIL_SAME(trait,name) \
  47. /**/
  48. #endif // !defined(BOOST_MPL_CFG_NO_HAS_XXX_TEMPLATE)
  49. #define BOOST_TTI_DETAIL_VM_CHECK_MORE_THAN_TWO(trait,...) \
  50. BOOST_PP_IIF \
  51. ( \
  52. BOOST_PP_EQUAL \
  53. ( \
  54. BOOST_PP_VARIADIC_SIZE(__VA_ARGS__), \
  55. 2 \
  56. ), \
  57. BOOST_TTI_DETAIL_VM_TRAIT_CHOOSE_FROM_TWO, \
  58. BOOST_TTI_DETAIL_VM_TRAIT_EXPAND_ARGUMENTS \
  59. ) \
  60. (trait,__VA_ARGS__) \
  61. /**/
  62. #define BOOST_TTI_DETAIL_VM_TRAIT_CHOOSE_FROM_TWO(trait,...) \
  63. BOOST_PP_IIF \
  64. ( \
  65. BOOST_PP_IS_BINARY \
  66. ( \
  67. BOOST_PP_VARIADIC_ELEM(1,__VA_ARGS__) \
  68. ), \
  69. BOOST_TTI_DETAIL_TRAIT_HAS_TEMPLATE_CHECK_PARAMS, \
  70. BOOST_TTI_DETAIL_VM_TRAIT_CHOOSE_IF_NIL \
  71. ) \
  72. ( \
  73. trait, \
  74. BOOST_PP_VARIADIC_ELEM(0,__VA_ARGS__), \
  75. BOOST_PP_VARIADIC_ELEM(1,__VA_ARGS__) \
  76. ) \
  77. /**/
  78. #define BOOST_TTI_DETAIL_VM_IS_NIL(param) \
  79. BOOST_PP_IS_EMPTY \
  80. ( \
  81. BOOST_PP_CAT(BOOST_TTI_DETAIL_IS_HELPER_,param) \
  82. ) \
  83. /**/
  84. #define BOOST_TTI_DETAIL_VM_TRAIT_CHOOSE_IF_NIL(trait,name,param) \
  85. BOOST_PP_IIF \
  86. ( \
  87. BOOST_TTI_DETAIL_VM_IS_NIL(param), \
  88. BOOST_TTI_DETAIL_TRAIT_HAS_TEMPLATE, \
  89. BOOST_TTI_DETAIL_VM_CALL_TRAIT_HAS_TEMPLATE_CHECK_PARAMS \
  90. ) \
  91. (trait,name,param) \
  92. /**/
  93. #define BOOST_TTI_DETAIL_VM_VARIADIC_TAIL(...) \
  94. BOOST_PP_SEQ_ENUM \
  95. ( \
  96. BOOST_PP_SEQ_TAIL \
  97. ( \
  98. BOOST_PP_VARIADIC_TO_SEQ(__VA_ARGS__) \
  99. ) \
  100. ) \
  101. /**/
  102. #define BOOST_TTI_DETAIL_VM_TRAIT_EXPAND_ARGUMENTS(trait,...) \
  103. BOOST_TTI_DETAIL_VM_CALL_TRAIT_HAS_TEMPLATE_CHECK_PARAMS \
  104. ( \
  105. trait, \
  106. BOOST_PP_VARIADIC_ELEM(0,__VA_ARGS__), \
  107. BOOST_TTI_DETAIL_VM_VARIADIC_TAIL(__VA_ARGS__) \
  108. ) \
  109. /**/
  110. #define BOOST_TTI_DETAIL_VM_TRAIT_HAS_TEMPLATE(trait,...) \
  111. BOOST_TTI_DETAIL_TRAIT_HAS_TEMPLATE \
  112. ( \
  113. trait, \
  114. BOOST_PP_VARIADIC_ELEM(0,__VA_ARGS__), \
  115. BOOST_PP_NIL \
  116. ) \
  117. /**/
  118. #define BOOST_TTI_DETAIL_VM_CT_INVOKE(trait,name,...) \
  119. BOOST_TTI_DETAIL_VM_TRAIT_HAS_TEMPLATE_CHECK_PARAMS(BOOST_PP_CAT(trait,_detail),name,__VA_ARGS__) \
  120. template<class BOOST_TTI_DETAIL_TP_T> \
  121. struct BOOST_PP_CAT(trait,_detail_vm_ct_invoke) : \
  122. BOOST_PP_CAT(trait,_detail)<BOOST_TTI_DETAIL_TP_T> \
  123. { \
  124. }; \
  125. /**/
  126. #define BOOST_TTI_DETAIL_VM_CALL_TRAIT_HAS_TEMPLATE_CHECK_PARAMS(trait,name,...) \
  127. BOOST_TTI_DETAIL_VM_CT_INVOKE(trait,name,__VA_ARGS__) \
  128. template<class BOOST_TTI_DETAIL_TP_T> \
  129. struct trait \
  130. { \
  131. typedef typename \
  132. boost::mpl::eval_if \
  133. < \
  134. BOOST_TTI_NAMESPACE::detail::enclosing_type<BOOST_TTI_DETAIL_TP_T>, \
  135. BOOST_PP_CAT(trait,_detail_vm_ct_invoke)<BOOST_TTI_DETAIL_TP_T>, \
  136. boost::mpl::false_ \
  137. >::type type; \
  138. BOOST_STATIC_CONSTANT(bool,value=type::value); \
  139. }; \
  140. /**/
  141. #endif // BOOST_PP_VARIADICS
  142. #endif // BOOST_TTI_DETAIL_VM_TEMPLATE_PARAMS_HPP