| 1 | |
| 2 | // (C) Copyright Edward Diener 2019 |
| 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_MEMBER_FUNCTION_TEMPLATE_HPP) |
| 8 | #define BOOST_TTI_MEMBER_FUNCTION_TEMPLATE_HPP |
| 9 | |
| 10 | #include <boost/config.hpp> |
| 11 | #include <boost/function_types/property_tags.hpp> |
| 12 | #include <boost/mpl/vector.hpp> |
| 13 | #include <boost/preprocessor/cat.hpp> |
| 14 | #include <boost/tti/detail/ddeftype.hpp> |
| 15 | #include <boost/tti/detail/dmem_fun_template.hpp> |
| 16 | #include <boost/tti/gen/has_member_function_template_gen.hpp> |
| 17 | #include <boost/tti/gen/namespace_gen.hpp> |
| 18 | |
| 19 | #if BOOST_PP_VARIADICS |
| 20 | |
| 21 | #include <boost/tti/detail/dmacro_fun_template.hpp> |
| 22 | |
| 23 | /* |
| 24 | |
| 25 | The succeeding comments in this file are in doxygen format. |
| 26 | |
| 27 | */ |
| 28 | |
| 29 | /** \file |
| 30 | */ |
| 31 | |
| 32 | /// A macro which expands to a metafunction which tests whether an inner member function template with a particular name exists. |
| 33 | /** |
| 34 | |
| 35 | BOOST_TTI_TRAIT_HAS_MEMBER_FUNCTION_TEMPLATE is a macro which expands to a metafunction. |
| 36 | The metafunction tests whether an inner member function template with a particular name exists. |
| 37 | The macro takes the form of BOOST_TTI_TRAIT_HAS_MEMBER_FUNCTION_TEMPLATE(trait,name,...) where |
| 38 | |
| 39 | trait = the name of the metafunction <br/> |
| 40 | name = inner member function template name <br/> |
| 41 | ... = variadic parameters. |
| 42 | |
| 43 | The variadic parameter(s) are either: |
| 44 | |
| 45 | A sequence of valid instantiations for the member function template parameters |
| 46 | ie. 'int,long,double' etc. |
| 47 | |
| 48 | or |
| 49 | |
| 50 | A single variadic parameter which is a Boost PP array whose elements are |
| 51 | a sequence of valid instantiations for the member function template parameters |
| 52 | ie. '(3,(int,long,double))' etc. This form is allowed in order to be compatible |
| 53 | with using the non-variadic form of this macro. |
| 54 | |
| 55 | BOOST_TTI_TRAIT_HAS_MEMBER_FUNCTION_TEMPLATE generates a metafunction called "trait" where 'trait' is the first macro parameter. |
| 56 | |
| 57 | @code |
| 58 | |
| 59 | template<class BOOST_TTI_TP_T,class BOOST_TTI_R,class BOOST_TTI_FS,class BOOST_TTI_TAG> |
| 60 | struct trait |
| 61 | { |
| 62 | static const value = unspecified; |
| 63 | typedef mpl::bool_<true-or-false> type; |
| 64 | }; |
| 65 | |
| 66 | The metafunction types and return: |
| 67 | |
| 68 | BOOST_TTI_TP_T = the enclosing type in which to look for our 'name'. |
| 69 | The enclosing type can be a class, struct, or union. |
| 70 | OR |
| 71 | a pointer to member function as a single type |
| 72 | which encapsulates a single instantiation of |
| 73 | the member function template. |
| 74 | |
| 75 | BOOST_TTI_TP_R = (optional) the return type of the member function template |
| 76 | in a single instantiation of the member function template |
| 77 | if the first parameter is the enclosing type. |
| 78 | |
| 79 | BOOST_TTI_TP_FS = (optional) the parameters of the member function template as a boost::mpl forward sequence |
| 80 | if the first parameter is the enclosing type and the member function template parameters |
| 81 | are not empty. These parameters are a single instantiation of the member function template. |
| 82 | |
| 83 | BOOST_TTI_TP_TAG = (optional) a boost::function_types tag to apply to the member function template |
| 84 | if the first parameter is the enclosing type and a tag is needed. |
| 85 | |
| 86 | returns = 'value' is true if the 'name' exists, |
| 87 | with the appropriate member function template type, |
| 88 | otherwise 'value' is false. |
| 89 | |
| 90 | @endcode |
| 91 | |
| 92 | */ |
| 93 | #define BOOST_TTI_TRAIT_HAS_MEMBER_FUNCTION_TEMPLATE(trait,name,...) \ |
| 94 | BOOST_TTI_DETAIL_TRAIT_HAS_MEMBER_FUNCTION_TEMPLATE \ |
| 95 | ( \ |
| 96 | trait, \ |
| 97 | name, \ |
| 98 | BOOST_TTI_DETAIL_FUN_TEMPLATE_VARIADIC_TO_ARRAY(__VA_ARGS__) \ |
| 99 | ) \ |
| 100 | template<class BOOST_TTI_TP_T,class BOOST_TTI_TP_R = BOOST_TTI_NAMESPACE::detail::deftype,class BOOST_TTI_TP_FS = boost::mpl::vector<>,class BOOST_TTI_TP_TAG = boost::function_types::null_tag> \ |
| 101 | struct trait \ |
| 102 | { \ |
| 103 | typedef typename \ |
| 104 | BOOST_PP_CAT(trait,_detail_hmft)<BOOST_TTI_TP_T,BOOST_TTI_TP_R,BOOST_TTI_TP_FS,BOOST_TTI_TP_TAG>::type type; \ |
| 105 | BOOST_STATIC_CONSTANT(bool,value=type::value); \ |
| 106 | }; \ |
| 107 | /**/ |
| 108 | |
| 109 | /// A macro which expands to a metafunction which tests whether an inner member function template with a particular name exists. |
| 110 | /** |
| 111 | |
| 112 | BOOST_TTI_HAS_MEMBER_FUNCTION_TEMPLATE is a macro which expands to a metafunction. |
| 113 | The metafunction tests whether an inner member function template with a particular name exists. |
| 114 | The macro takes the form of BOOST_TTI_HAS_MEMBER_FUNCTION_TEMPLATE(name,...) where |
| 115 | |
| 116 | name = inner member function template name <br/> |
| 117 | ... = variadic parameters. |
| 118 | |
| 119 | The variadic parameter(s) are either: |
| 120 | |
| 121 | A sequence of valid instantiations for the member function template parameters |
| 122 | ie. 'int,long,double' etc. |
| 123 | |
| 124 | or |
| 125 | |
| 126 | A single variadic parameter which is a Boost PP array whose elements are |
| 127 | a sequence of valid instantiations for the member function template parameters |
| 128 | ie. '(3,(int,long,double))' etc. This form is allowed in order to be compatible |
| 129 | with using the non-variadic form of this macro. |
| 130 | |
| 131 | BOOST_TTI_HAS_MEMBER_FUNCTION_TEMPLATE generates a metafunction called "has_member_function_template_'name'" where 'name' is the first macro parameter. |
| 132 | |
| 133 | @code |
| 134 | |
| 135 | template<class BOOST_TTI_TP_T,class BOOST_TTI_R,class BOOST_TTI_FS,class BOOST_TTI_TAG> |
| 136 | struct has_member_function_template_'name' |
| 137 | { |
| 138 | static const value = unspecified; |
| 139 | typedef mpl::bool_<true-or-false> type; |
| 140 | }; |
| 141 | |
| 142 | The metafunction types and return: |
| 143 | |
| 144 | BOOST_TTI_TP_T = the enclosing type in which to look for our 'name'. |
| 145 | The enclosing type can be a class, struct, or union. |
| 146 | OR |
| 147 | a pointer to member function as a single type |
| 148 | which encapsulates a single instantiation of |
| 149 | the member function template. |
| 150 | |
| 151 | BOOST_TTI_TP_R = (optional) the return type of the member function template |
| 152 | in a single instantiation of the member function template |
| 153 | if the first parameter is the enclosing type. |
| 154 | |
| 155 | BOOST_TTI_TP_FS = (optional) the parameters of the member function template as a boost::mpl forward sequence |
| 156 | if the first parameter is the enclosing type and the member function template parameters |
| 157 | are not empty. These parameters are a single instantiation of the member function template. |
| 158 | |
| 159 | BOOST_TTI_TP_TAG = (optional) a boost::function_types tag to apply to the member function template |
| 160 | if the first parameter is the enclosing type and a tag is needed. |
| 161 | |
| 162 | returns = 'value' is true if the 'name' exists, |
| 163 | with the appropriate member function template type, |
| 164 | otherwise 'value' is false. |
| 165 | |
| 166 | @endcode |
| 167 | |
| 168 | */ |
| 169 | #define BOOST_TTI_HAS_MEMBER_FUNCTION_TEMPLATE(name,...) \ |
| 170 | BOOST_TTI_TRAIT_HAS_MEMBER_FUNCTION_TEMPLATE \ |
| 171 | ( \ |
| 172 | BOOST_TTI_HAS_MEMBER_FUNCTION_TEMPLATE_GEN(name), \ |
| 173 | name, \ |
| 174 | __VA_ARGS__ \ |
| 175 | ) \ |
| 176 | /**/ |
| 177 | |
| 178 | #else // !BOOST_PP_VARIADICS |
| 179 | |
| 180 | /* |
| 181 | |
| 182 | The succeeding comments in this file are in doxygen format. |
| 183 | |
| 184 | */ |
| 185 | |
| 186 | /** \file |
| 187 | */ |
| 188 | |
| 189 | /// A macro which expands to a metafunction which tests whether an inner member function template with a particular name exists. |
| 190 | /** |
| 191 | |
| 192 | BOOST_TTI_TRAIT_HAS_MEMBER_FUNCTION_TEMPLATE is a macro which expands to a metafunction. |
| 193 | The metafunction tests whether an inner member function template with a particular name exists. |
| 194 | The macro takes the form of BOOST_TTI_TRAIT_HAS_MEMBER_FUNCTION_TEMPLATE(trait,name,pparray) where |
| 195 | |
| 196 | trait = the name of the metafunction <br/> |
| 197 | name = inner member function template name <br/> |
| 198 | pparray = A Boost PP array whose elements are a sequence of valid instantiations for the |
| 199 | member function template parameters ie. '(3,(int,long,double))' etc. |
| 200 | |
| 201 | BOOST_TTI_TRAIT_HAS_MEMBER_FUNCTION_TEMPLATE generates a metafunction called "trait" where 'trait' is the first macro parameter. |
| 202 | |
| 203 | @code |
| 204 | |
| 205 | template<class BOOST_TTI_TP_T,class BOOST_TTI_R,class BOOST_TTI_FS,class BOOST_TTI_TAG> |
| 206 | struct trait |
| 207 | { |
| 208 | static const value = unspecified; |
| 209 | typedef mpl::bool_<true-or-false> type; |
| 210 | }; |
| 211 | |
| 212 | The metafunction types and return: |
| 213 | |
| 214 | BOOST_TTI_TP_T = the enclosing type in which to look for our 'name'. |
| 215 | The enclosing type can be a class, struct, or union. |
| 216 | OR |
| 217 | a pointer to member function as a single type |
| 218 | which encapsulates a single instantiation of |
| 219 | the member function template. |
| 220 | |
| 221 | BOOST_TTI_TP_R = (optional) the return type of the member function template |
| 222 | in a single instantiation of the member function template |
| 223 | if the first parameter is the enclosing type. |
| 224 | |
| 225 | BOOST_TTI_TP_FS = (optional) the parameters of the member function template as a boost::mpl forward sequence |
| 226 | if the first parameter is the enclosing type and the member function template parameters |
| 227 | are not empty. These parameters are a single instantiation of the member function template. |
| 228 | |
| 229 | BOOST_TTI_TP_TAG = (optional) a boost::function_types tag to apply to the member function template |
| 230 | if the first parameter is the enclosing type and a tag is needed. |
| 231 | |
| 232 | returns = 'value' is true if the 'name' exists, |
| 233 | with the appropriate member function template type, |
| 234 | otherwise 'value' is false. |
| 235 | |
| 236 | @endcode |
| 237 | |
| 238 | */ |
| 239 | #define BOOST_TTI_TRAIT_HAS_MEMBER_FUNCTION_TEMPLATE(trait,name,pparray) \ |
| 240 | BOOST_TTI_DETAIL_TRAIT_HAS_MEMBER_FUNCTION_TEMPLATE(trait,name,pparray) \ |
| 241 | template<class BOOST_TTI_TP_T,class BOOST_TTI_TP_R = BOOST_TTI_NAMESPACE::detail::deftype,class BOOST_TTI_TP_FS = boost::mpl::vector<>,class BOOST_TTI_TP_TAG = boost::function_types::null_tag> \ |
| 242 | struct trait \ |
| 243 | { \ |
| 244 | typedef typename \ |
| 245 | BOOST_PP_CAT(trait,_detail_hmft)<BOOST_TTI_TP_T,BOOST_TTI_TP_R,BOOST_TTI_TP_FS,BOOST_TTI_TP_TAG>::type type; \ |
| 246 | BOOST_STATIC_CONSTANT(bool,value=type::value); \ |
| 247 | }; \ |
| 248 | |
| 249 | /**/ |
| 250 | |
| 251 | /// A macro which expands to a metafunction which tests whether an inner member function template with a particular name exists. |
| 252 | /** |
| 253 | |
| 254 | BOOST_TTI_HAS_MEMBER_FUNCTION_TEMPLATE is a macro which expands to a metafunction. |
| 255 | The metafunction tests whether an inner member function template with a particular name exists. |
| 256 | The macro takes the form of BOOST_TTI_HAS_MEMBER_FUNCTION_TEMPLATE(name,pparray) where |
| 257 | |
| 258 | name = inner member function template name <br/> |
| 259 | pparray = A Boost PP array whose elements are a sequence of valid instantiations for the |
| 260 | member function template parameters ie. '(3,(int,long,double))' etc. |
| 261 | |
| 262 | BOOST_TTI_HAS_MEMBER_FUNCTION_TEMPLATE generates a metafunction called "has_member_function_template_'name'" where 'name' is the first macro parameter. |
| 263 | |
| 264 | @code |
| 265 | |
| 266 | template<class BOOST_TTI_TP_T,class BOOST_TTI_R,class BOOST_TTI_FS,class BOOST_TTI_TAG> |
| 267 | struct has_member_function_template_'name' |
| 268 | { |
| 269 | static const value = unspecified; |
| 270 | typedef mpl::bool_<true-or-false> type; |
| 271 | }; |
| 272 | |
| 273 | The metafunction types and return: |
| 274 | |
| 275 | BOOST_TTI_TP_T = the enclosing type in which to look for our 'name'. |
| 276 | The enclosing type can be a class, struct, or union. |
| 277 | OR |
| 278 | a pointer to member function as a single type |
| 279 | which encapsulates a single instantiation of |
| 280 | the member function template. |
| 281 | |
| 282 | BOOST_TTI_TP_R = (optional) the return type of the member function template |
| 283 | in a single instantiation of the member function template |
| 284 | if the first parameter is the enclosing type. |
| 285 | |
| 286 | BOOST_TTI_TP_FS = (optional) the parameters of the member function template as a boost::mpl forward sequence |
| 287 | if the first parameter is the enclosing type and the member function template parameters |
| 288 | are not empty. These parameters are a single instantiation of the member function template. |
| 289 | |
| 290 | BOOST_TTI_TP_TAG = (optional) a boost::function_types tag to apply to the member function template |
| 291 | if the first parameter is the enclosing type and a tag is needed. |
| 292 | |
| 293 | returns = 'value' is true if the 'name' exists, |
| 294 | with the appropriate member function template type, |
| 295 | otherwise 'value' is false. |
| 296 | |
| 297 | @endcode |
| 298 | |
| 299 | */ |
| 300 | #define BOOST_TTI_HAS_MEMBER_FUNCTION_TEMPLATE(name,pparray) \ |
| 301 | BOOST_TTI_TRAIT_HAS_MEMBER_FUNCTION_TEMPLATE \ |
| 302 | ( \ |
| 303 | BOOST_TTI_HAS_MEMBER_FUNCTION_TEMPLATE_GEN(name), \ |
| 304 | name, \ |
| 305 | pparray \ |
| 306 | ) \ |
| 307 | /**/ |
| 308 | |
| 309 | #endif // BOOST_PP_VARIADICS |
| 310 | |
| 311 | #endif // BOOST_TTI_MEMBER_FUNCTION_TEMPLATE_HPP |
| 312 | |