annotate DEPENDENCIES/generic/include/boost/tti/has_template.hpp @ 133:4acb5d8d80b6 tip

Don't fail environmental check if README.md exists (but .txt and no-suffix don't)
author Chris Cannam
date Tue, 30 Jul 2019 12:25:44 +0100
parents 2665513ce2d3
children
rev   line source
Chris@16 1
Chris@16 2 // (C) Copyright Edward Diener 2011,2012
Chris@16 3 // Use, modification and distribution are subject to the Boost Software License,
Chris@16 4 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
Chris@16 5 // http://www.boost.org/LICENSE_1_0.txt).
Chris@16 6
Chris@16 7 /*
Chris@16 8
Chris@16 9 The succeeding comments in this file are in doxygen format.
Chris@16 10
Chris@16 11 */
Chris@16 12
Chris@16 13 /** \file
Chris@16 14 */
Chris@16 15
Chris@16 16 #if !defined(BOOST_TTI_HAS_TEMPLATE_HPP)
Chris@16 17 #define BOOST_TTI_HAS_TEMPLATE_HPP
Chris@16 18
Chris@16 19 #include <boost/config.hpp>
Chris@16 20 #include <boost/tti/gen/has_template_gen.hpp>
Chris@16 21 #include <boost/preprocessor/config/config.hpp>
Chris@16 22 #include <boost/preprocessor/control/iif.hpp>
Chris@16 23
Chris@16 24 #if BOOST_PP_VARIADICS
Chris@16 25
Chris@16 26 #include <boost/preprocessor/comparison/equal.hpp>
Chris@16 27 #include <boost/preprocessor/variadic/elem.hpp>
Chris@16 28 #include <boost/preprocessor/variadic/size.hpp>
Chris@16 29 #include <boost/tti/detail/dvm_template_params.hpp>
Chris@16 30
Chris@16 31 /// Expands to a metafunction which tests whether an inner class template with a particular name exists.
Chris@16 32 /**
Chris@16 33
Chris@16 34 trait = the name of the metafunction.
Chris@16 35 ... = variadic parameters.
Chris@16 36
Chris@16 37 The first variadic parameter is the inner class template name.
Chris@16 38
Chris@16 39 Following variadic parameters are optional.
Chris@16 40
Chris@16 41 If no following variadic parameters exist, then the inner class template
Chris@16 42 being introspected must be all template type parameters ( template parameters
Chris@16 43 starting with `class` or `typename` ) and any number of template type parameters
Chris@16 44 can occur.
Chris@16 45
Chris@16 46 If the second variadic parameter is BOOST_PP_NIL and no other variadic
Chris@16 47 parameter is given, then just as in the previous case the inner class template
Chris@16 48 being introspected must be all template type parameters ( template parameters
Chris@16 49 starting with `class` or `typename` ) and any number of template type parameters
Chris@16 50 can occur. This form is allowed in order to be consistent with using the
Chris@16 51 non-variadic form of this macro.
Chris@16 52
Chris@16 53 If the second variadic parameter is a Boost preprocessor library array and no other
Chris@16 54 variadic parameter is given, then the inner class template must have its template
Chris@16 55 parameters matching the sequence in the tuple portion of the Boost PP array. This
Chris@16 56 form is allowed in order to be consistent with using the non-variadic form of this
Chris@16 57 macro.
Chris@16 58
Chris@16 59 Otherwise the inner class template must have its template parameters matching the
Chris@16 60 sequence of the optional variadic parameters.
Chris@16 61
Chris@16 62 generates a metafunction called "trait" where 'trait' is the first macro parameter.
Chris@16 63
Chris@16 64 template<class BOOST_TTI_TP_T>
Chris@16 65 struct trait
Chris@16 66 {
Chris@16 67 static const value = unspecified;
Chris@16 68 typedef mpl::bool_<true-or-false> type;
Chris@16 69 };
Chris@16 70
Chris@16 71 The metafunction types and return:
Chris@16 72
Chris@16 73 BOOST_TTI_TP_T = the enclosing type in which to look for our 'name'.
Chris@16 74
Chris@16 75 returns = 'value' is true if the 'name' template exists within the enclosing type,
Chris@16 76 otherwise 'value' is false.
Chris@16 77
Chris@16 78 Examples:
Chris@16 79
Chris@16 80 1) Search for an inner class template called 'MyTemplate', with all template type parameters,
Chris@16 81 nested within the class 'MyClass' using a metafunction name of 'MyMeta'.
Chris@16 82
Chris@16 83 BOOST_TTI_TRAIT_HAS_TEMPLATE(MyMeta,MyTemplate)
Chris@16 84
Chris@16 85 or
Chris@16 86
Chris@16 87 BOOST_TTI_TRAIT_HAS_TEMPLATE(MyMeta,MyTemplate,BOOST_PP_NIL) // Non-variadic macro form
Chris@16 88
Chris@16 89 MyMeta<MyClass>::value
Chris@16 90
Chris@16 91 is a compile time boolean constant which is either 'true' or 'false'
Chris@16 92 if the nested template exists.
Chris@16 93
Chris@16 94 2) Search for an inner class template called 'MyTemplate', with template parameters
Chris@16 95 of 'class T,int x,template<class> class U', nested within the class 'MyClass'
Chris@16 96 using a metafunction name of 'MyMeta'.
Chris@16 97
Chris@16 98 BOOST_TTI_TRAIT_HAS_TEMPLATE(MyMeta,MyTemplate,class,int,template<class> class)
Chris@16 99
Chris@16 100 or
Chris@16 101
Chris@16 102 BOOST_TTI_TRAIT_HAS_TEMPLATE(MyMeta,MyTemplate,(3,(class,int,template<class> class))) // Non-variadic macro form
Chris@16 103
Chris@16 104 MyMeta<MyClass>::value
Chris@16 105
Chris@16 106 is a compile time boolean constant which is either 'true' or 'false'
Chris@16 107 if the nested template exists.
Chris@16 108
Chris@16 109 */
Chris@16 110 #define BOOST_TTI_TRAIT_HAS_TEMPLATE(trait,...) \
Chris@16 111 BOOST_PP_IIF \
Chris@16 112 ( \
Chris@16 113 BOOST_PP_EQUAL \
Chris@16 114 ( \
Chris@16 115 BOOST_PP_VARIADIC_SIZE(__VA_ARGS__), \
Chris@16 116 1 \
Chris@16 117 ), \
Chris@16 118 BOOST_TTI_DETAIL_VM_TRAIT_HAS_TEMPLATE, \
Chris@16 119 BOOST_TTI_DETAIL_VM_CHECK_MORE_THAN_TWO \
Chris@16 120 ) \
Chris@16 121 (trait,__VA_ARGS__) \
Chris@16 122 /**/
Chris@16 123
Chris@16 124 /// Expands to a metafunction which tests whether an inner class template with a particular name exists.
Chris@16 125 /**
Chris@16 126
Chris@16 127 ... = variadic parameters.
Chris@16 128
Chris@16 129 The first variadic parameter is the inner class template name.
Chris@16 130
Chris@16 131 Following variadic parameters are optional.
Chris@16 132
Chris@16 133 If no following variadic parameters exist, then the inner class template
Chris@16 134 being introspected must be all template type parameters ( template parameters
Chris@16 135 starting with `class` or `typename` ) and any number of template type parameters
Chris@16 136 can occur.
Chris@16 137
Chris@16 138 If the second variadic parameter is BOOST_PP_NIL and no other variadic
Chris@16 139 parameter is given, then just as in the previous case the inner class template
Chris@16 140 being introspected must be all template type parameters ( template parameters
Chris@16 141 starting with `class` or `typename` ) and any number of template type parameters
Chris@16 142 can occur. This form is allowed in order to be consistent with using the
Chris@16 143 non-variadic form of this macro.
Chris@16 144
Chris@16 145 If the second variadic parameter is a Boost preprocessor library array and no other
Chris@16 146 variadic parameter is given, then the inner class template must have its template
Chris@16 147 parameters matching the sequence in the tuple portion of the Boost PP array. This
Chris@16 148 form is allowed in order to be consistent with using the non-variadic form of this
Chris@16 149 macro.
Chris@16 150
Chris@16 151 Otherwise the inner class template must have its template parameters matching the
Chris@16 152 sequence of the optional variadic parameters.
Chris@16 153
Chris@16 154 generates a metafunction called "has_template_'name'" where 'name' is the first variadic parameter.
Chris@16 155
Chris@16 156 template<class BOOST_TTI_TP_T>
Chris@16 157 struct has_template_'name'
Chris@16 158 {
Chris@16 159 static const value = unspecified;
Chris@16 160 typedef mpl::bool_<true-or-false> type;
Chris@16 161 };
Chris@16 162
Chris@16 163 The metafunction types and return:
Chris@16 164
Chris@16 165 BOOST_TTI_TP_T = the enclosing type in which to look for our 'name'.
Chris@16 166
Chris@16 167 returns = 'value' is true if the 'name' template exists within the enclosing type,
Chris@16 168 otherwise 'value' is false.
Chris@16 169
Chris@16 170 Examples:
Chris@16 171
Chris@16 172 1) Search for an inner class template called 'MyTemplate', with all template type parameters,
Chris@16 173 nested within the class 'MyClass'.
Chris@16 174
Chris@16 175 BOOST_TTI_HAS_TEMPLATE(MyTemplate)
Chris@16 176
Chris@16 177 or
Chris@16 178
Chris@16 179 BOOST_TTI_HAS_TEMPLATE(MyTemplate,BOOST_PP_NIL) // Non-variadic macro form
Chris@16 180
Chris@16 181 has_template_MyTemplate<MyClass>::value
Chris@16 182
Chris@16 183 is a compile time boolean constant which is either 'true' or 'false'
Chris@16 184 if the nested template exists.
Chris@16 185
Chris@16 186 2) Search for an inner class template called 'MyTemplate' with template parameters
Chris@16 187 of 'class T,int x,template<class> class U' nested within the class 'MyClass'.
Chris@16 188
Chris@16 189 BOOST_TTI_HAS_TEMPLATE(MyTemplate,class,int,template<class> class)
Chris@16 190
Chris@16 191 or
Chris@16 192
Chris@16 193 BOOST_TTI_HAS_TEMPLATE(MyTemplate,(3,(class,int,template<class> class))) // Non-variadic macro form
Chris@16 194
Chris@16 195 has_template_MyTemplate<MyClass>::value
Chris@16 196
Chris@16 197 is a compile time boolean constant which is either 'true' or 'false'
Chris@16 198 if the nested template exists.
Chris@16 199
Chris@16 200 */
Chris@16 201 #define BOOST_TTI_HAS_TEMPLATE(...) \
Chris@16 202 BOOST_TTI_TRAIT_HAS_TEMPLATE \
Chris@16 203 ( \
Chris@16 204 BOOST_TTI_HAS_TEMPLATE_GEN \
Chris@16 205 ( \
Chris@16 206 BOOST_PP_VARIADIC_ELEM(0,__VA_ARGS__) \
Chris@16 207 ), \
Chris@16 208 __VA_ARGS__ \
Chris@16 209 ) \
Chris@16 210 /**/
Chris@16 211
Chris@16 212 #else // !BOOST_PP_VARIADICS
Chris@16 213
Chris@16 214 #include <boost/preprocessor/detail/is_binary.hpp>
Chris@16 215 #include <boost/tti/detail/dtemplate.hpp>
Chris@16 216 #include <boost/tti/detail/dtemplate_params.hpp>
Chris@16 217
Chris@16 218 /// Expands to a metafunction which tests whether an inner class template with a particular name exists.
Chris@16 219 /**
Chris@16 220
Chris@16 221 trait = the name of the metafunction.
Chris@16 222 name = the inner class template name.
Chris@16 223 params = If the parameter is BOOST_PP_NIL the inner class template
Chris@16 224 being introspected must be all template type parameters ( template parameters
Chris@16 225 starting with `class` or `typename` ) and any number of template type parameters
Chris@16 226 can occur.
Chris@16 227
Chris@16 228 If the parameter is a Boost preprocessor library array, then the inner class
Chris@16 229 template must have its template parameters matching the sequence in the tuple portion
Chris@16 230 of the Boost PP array.
Chris@16 231
Chris@16 232 Otherwise a compiler error occurs.
Chris@16 233
Chris@16 234 generates a metafunction called "trait" where 'trait' is the first macro parameter.
Chris@16 235
Chris@16 236 template<class BOOST_TTI_TP_T>
Chris@16 237 struct trait
Chris@16 238 {
Chris@16 239 static const value = unspecified;
Chris@16 240 typedef mpl::bool_<true-or-false> type;
Chris@16 241 };
Chris@16 242
Chris@16 243 The metafunction types and return:
Chris@16 244
Chris@16 245 BOOST_TTI_TP_T = the enclosing type in which to look for our 'name'.
Chris@16 246
Chris@16 247 returns = 'value' is true if the 'name' template exists within the enclosing type,
Chris@16 248 otherwise 'value' is false.
Chris@16 249
Chris@16 250 Examples:
Chris@16 251
Chris@16 252 1) Search for an inner class template called 'MyTemplate', with all template type parameters,
Chris@16 253 nested within the class 'MyClass' using a metafunction name of 'MyMeta'.
Chris@16 254
Chris@16 255 BOOST_TTI_TRAIT_HAS_TEMPLATE(MyMeta,MyTemplate,BOOST_PP_NIL)
Chris@16 256
Chris@16 257 MyMeta<MyClass>::value
Chris@16 258
Chris@16 259 is a compile time boolean constant which is either 'true' or 'false'
Chris@16 260 if the nested template exists.
Chris@16 261
Chris@16 262 2) Search for an inner class template called 'MyTemplate', with template parameters
Chris@16 263 of 'class T,int x,template<class> class U', nested within the class 'MyClass'
Chris@16 264 using a metafunction name of 'MyMeta'.
Chris@16 265
Chris@16 266 BOOST_TTI_TRAIT_HAS_TEMPLATE(MyMeta,MyTemplate,(3,(class,int,template<class> class)))
Chris@16 267
Chris@16 268 MyMeta<MyClass>::value
Chris@16 269
Chris@16 270 is a compile time boolean constant which is either 'true' or 'false'
Chris@16 271 if the nested template exists.
Chris@16 272
Chris@16 273 */
Chris@16 274 #define BOOST_TTI_TRAIT_HAS_TEMPLATE(trait,name,params) \
Chris@16 275 BOOST_PP_IIF \
Chris@16 276 ( \
Chris@16 277 BOOST_PP_IS_BINARY(params), \
Chris@16 278 BOOST_TTI_DETAIL_TRAIT_HAS_TEMPLATE_CHECK_PARAMS, \
Chris@16 279 BOOST_TTI_DETAIL_TRAIT_CHECK_IS_NIL \
Chris@16 280 ) \
Chris@16 281 (trait,name,params) \
Chris@16 282 /**/
Chris@16 283
Chris@16 284 /// Expands to a metafunction which tests whether an inner class template with a particular name exists.
Chris@16 285 /**
Chris@16 286
Chris@16 287 name = the inner class template name.
Chris@16 288 params = If the parameter is BOOST_PP_NIL the inner class template
Chris@16 289 being introspected must be all template type parameters ( template parameters
Chris@16 290 starting with `class` or `typename` ) and any number of template type parameters
Chris@16 291 can occur.
Chris@16 292
Chris@16 293 If the parameter is a Boost preprocessor library array, then the inner class
Chris@16 294 template must have its template parameters matching the sequence in the tuple portion
Chris@16 295 of the Boost PP array.
Chris@16 296
Chris@16 297 Otherwise a compiler error occurs.
Chris@16 298
Chris@16 299 generates a metafunction called "has_template_'name'" where 'name' is the first macro parameter.
Chris@16 300
Chris@16 301 template<class BOOST_TTI_TP_T>
Chris@16 302 struct trait
Chris@16 303 {
Chris@16 304 static const value = unspecified;
Chris@16 305 typedef mpl::bool_<true-or-false> type;
Chris@16 306 };
Chris@16 307
Chris@16 308 The metafunction types and return:
Chris@16 309
Chris@16 310 BOOST_TTI_TP_T = the enclosing type in which to look for our 'name'.
Chris@16 311
Chris@16 312 returns = 'value' is true if the 'name' template exists within the enclosing type,
Chris@16 313 otherwise 'value' is false.
Chris@16 314
Chris@16 315 Examples:
Chris@16 316
Chris@16 317 1) Search for an inner class template called 'MyTemplate', with all template type parameters,
Chris@16 318 nested within the class 'MyClass'.
Chris@16 319
Chris@16 320 BOOST_TTI_HAS_TEMPLATE(MyTemplate,BOOST_PP_NIL)
Chris@16 321
Chris@16 322 has_template_MyTemplate<MyClass>::value
Chris@16 323
Chris@16 324 is a compile time boolean constant which is either 'true' or 'false'
Chris@16 325 if the nested template exists.
Chris@16 326
Chris@16 327 2) Search for an inner class template called 'MyTemplate' with template parameters
Chris@16 328 of 'class T,int x,template<class> class U' nested within the class 'MyClass'.
Chris@16 329
Chris@16 330 BOOST_TTI_HAS_TEMPLATE(MyTemplate,(3,(class,int,template<class> class)))
Chris@16 331
Chris@16 332 has_template_MyTemplate<MyClass>::value
Chris@16 333
Chris@16 334 is a compile time boolean constant which is either 'true' or 'false'
Chris@16 335 if the nested template exists.
Chris@16 336
Chris@16 337 */
Chris@16 338 #define BOOST_TTI_HAS_TEMPLATE(name,params) \
Chris@16 339 BOOST_TTI_TRAIT_HAS_TEMPLATE \
Chris@16 340 ( \
Chris@16 341 BOOST_TTI_HAS_TEMPLATE_GEN(name), \
Chris@16 342 name, \
Chris@16 343 params \
Chris@16 344 ) \
Chris@16 345 /**/
Chris@16 346
Chris@16 347 #endif // BOOST_PP_VARIADICS
Chris@16 348 #endif // BOOST_TTI_HAS_TEMPLATE_HPP