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