|
||||
File indexing completed on 2025-01-30 10:01:20
0001 0002 // (C) Copyright Edward Diener 2011,2012 0003 // Use, modification and distribution are subject to the Boost Software License, 0004 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at 0005 // http://www.boost.org/LICENSE_1_0.txt). 0006 0007 #if !defined(BOOST_TTI_HAS_TEMPLATE_HPP) 0008 #define BOOST_TTI_HAS_TEMPLATE_HPP 0009 0010 /* 0011 0012 The succeeding comments in this file are in doxygen format. 0013 0014 */ 0015 0016 /** \file 0017 */ 0018 0019 #include <boost/tti/gen/has_template_gen.hpp> 0020 #include <boost/preprocessor/config/config.hpp> 0021 #include <boost/preprocessor/control/iif.hpp> 0022 0023 #if BOOST_PP_VARIADICS 0024 0025 #include <boost/preprocessor/comparison/equal.hpp> 0026 #include <boost/preprocessor/variadic/elem.hpp> 0027 #include <boost/preprocessor/variadic/size.hpp> 0028 #include <boost/tti/detail/dvm_template_params.hpp> 0029 0030 /// A macro which expands to a metafunction which tests whether an inner class template with a particular name exists. 0031 /** 0032 0033 BOOST_TTI_TRAIT_HAS_TEMPLATE is a macro which expands to a metafunction. 0034 The metafunction tests whether an inner class template with a particular name exists. 0035 The macro takes the form of BOOST_TTI_TRAIT_HAS_TEMPLATE(trait,...) where 0036 0037 trait = the name of the metafunction <br/> 0038 ... = variadic parameters. 0039 0040 The first variadic parameter is the inner class template name. 0041 0042 Following variadic parameters are optional. 0043 0044 If no following variadic parameters exist, then the inner class template 0045 being introspected must be all template type parameters ( template parameters 0046 starting with `class` or `typename` ) and any number of template type parameters 0047 can occur. 0048 0049 If the second variadic parameter is BOOST_PP_NIL and no other variadic 0050 parameter is given, then just as in the previous case the inner class template 0051 being introspected must be all template type parameters ( template parameters 0052 starting with `class` or `typename` ) and any number of template type parameters 0053 can occur. This form is allowed in order to be consistent with using the 0054 non-variadic form of this macro. 0055 0056 If the second variadic parameter is a Boost preprocessor library array and no other 0057 variadic parameter is given, then the inner class template must have its template 0058 parameters matching the sequence in the tuple portion of the Boost PP array. This 0059 form is allowed in order to be consistent with using the non-variadic form of this 0060 macro. 0061 0062 Otherwise the inner class template must have its template parameters matching the 0063 sequence of the optional variadic parameters. 0064 0065 BOOST_TTI_TRAIT_HAS_TEMPLATE generates a metafunction called "trait" where 'trait' is the first macro parameter. 0066 0067 @code 0068 0069 template<class BOOST_TTI_TP_T> 0070 struct trait 0071 { 0072 static const value = unspecified; 0073 typedef mpl::bool_<true-or-false> type; 0074 }; 0075 0076 The metafunction types and return: 0077 0078 BOOST_TTI_TP_T = the enclosing type in which to look for our 'name'. 0079 The enclosing type can be a class, struct, or union. 0080 0081 returns = 'value' is true if the 'name' template exists within the enclosing type, 0082 otherwise 'value' is false. 0083 0084 @endcode 0085 0086 Examples: 0087 0088 @code 0089 0090 1) Search for an inner class template called 'MyTemplate', with all template type parameters, 0091 nested within the class 'MyClass' using a metafunction name of 'MyMeta'. 0092 0093 BOOST_TTI_TRAIT_HAS_TEMPLATE(MyMeta,MyTemplate) 0094 0095 or 0096 0097 BOOST_TTI_TRAIT_HAS_TEMPLATE(MyMeta,MyTemplate,BOOST_PP_NIL) // Non-variadic macro form 0098 0099 MyMeta<MyClass>::value 0100 0101 is a compile time boolean constant which is either 'true' or 'false' 0102 if the nested template exists. 0103 0104 2) Search for an inner class template called 'MyTemplate', with template parameters 0105 of 'class T,int x,template<class> class U', nested within the class 'MyClass' 0106 using a metafunction name of 'MyMeta'. 0107 0108 BOOST_TTI_TRAIT_HAS_TEMPLATE(MyMeta,MyTemplate,class,int,template<class> class) 0109 0110 or 0111 0112 BOOST_TTI_TRAIT_HAS_TEMPLATE(MyMeta,MyTemplate,(3,(class,int,template<class> class))) // Non-variadic macro form 0113 0114 MyMeta<MyClass>::value 0115 0116 is a compile time boolean constant which is either 'true' or 'false' 0117 if the nested template exists. 0118 0119 @endcode 0120 0121 */ 0122 #define BOOST_TTI_TRAIT_HAS_TEMPLATE(trait,...) \ 0123 BOOST_PP_IIF \ 0124 ( \ 0125 BOOST_PP_EQUAL \ 0126 ( \ 0127 BOOST_PP_VARIADIC_SIZE(__VA_ARGS__), \ 0128 1 \ 0129 ), \ 0130 BOOST_TTI_DETAIL_VM_TRAIT_HAS_TEMPLATE, \ 0131 BOOST_TTI_DETAIL_VM_CHECK_MORE_THAN_TWO \ 0132 ) \ 0133 (trait,__VA_ARGS__) \ 0134 /**/ 0135 0136 /// A macro which expands to a metafunction which tests whether an inner class template with a particular name exists. 0137 /** 0138 0139 BOOST_TTI_HAS_TEMPLATE is a macro which expands to a metafunction. 0140 The metafunction tests whether an inner class template with a particular name exists. 0141 The macro takes the form of BOOST_TTI_HAS_TEMPLATE(...) where 0142 0143 ... = variadic parameters. 0144 0145 The first variadic parameter is the inner class template name. 0146 0147 Following variadic parameters are optional. 0148 0149 If no following variadic parameters exist, then the inner class template 0150 being introspected must be all template type parameters ( template parameters 0151 starting with `class` or `typename` ) and any number of template type parameters 0152 can occur. 0153 0154 If the second variadic parameter is BOOST_PP_NIL and no other variadic 0155 parameter is given, then just as in the previous case the inner class template 0156 being introspected must be all template type parameters ( template parameters 0157 starting with `class` or `typename` ) and any number of template type parameters 0158 can occur. This form is allowed in order to be consistent with using the 0159 non-variadic form of this macro. 0160 0161 If the second variadic parameter is a Boost preprocessor library array and no other 0162 variadic parameter is given, then the inner class template must have its template 0163 parameters matching the sequence in the tuple portion of the Boost PP array. This 0164 form is allowed in order to be consistent with using the non-variadic form of this 0165 macro. 0166 0167 Otherwise the inner class template must have its template parameters matching the 0168 sequence of the optional variadic parameters. 0169 0170 BOOST_TTI_HAS_TEMPLATE generates a metafunction called "has_template_'name'" where 'name' is the first variadic parameter. 0171 0172 @code 0173 0174 template<class BOOST_TTI_TP_T> 0175 struct has_template_'name' 0176 { 0177 static const value = unspecified; 0178 typedef mpl::bool_<true-or-false> type; 0179 }; 0180 0181 The metafunction types and return: 0182 0183 BOOST_TTI_TP_T = the enclosing type in which to look for our 'name'. 0184 The enclosing type can be a class, struct, or union. 0185 0186 returns = 'value' is true if the 'name' template exists within the enclosing type, 0187 otherwise 'value' is false. 0188 0189 @endcode 0190 0191 Examples: 0192 0193 @code 0194 0195 1) Search for an inner class template called 'MyTemplate', with all template type parameters, 0196 nested within the class 'MyClass'. 0197 0198 BOOST_TTI_HAS_TEMPLATE(MyTemplate) 0199 0200 or 0201 0202 BOOST_TTI_HAS_TEMPLATE(MyTemplate,BOOST_PP_NIL) // Non-variadic macro form 0203 0204 has_template_MyTemplate<MyClass>::value 0205 0206 is a compile time boolean constant which is either 'true' or 'false' 0207 if the nested template exists. 0208 0209 2) Search for an inner class template called 'MyTemplate' with template parameters 0210 of 'class T,int x,template<class> class U' nested within the class 'MyClass'. 0211 0212 BOOST_TTI_HAS_TEMPLATE(MyTemplate,class,int,template<class> class) 0213 0214 or 0215 0216 BOOST_TTI_HAS_TEMPLATE(MyTemplate,(3,(class,int,template<class> class))) // Non-variadic macro form 0217 0218 has_template_MyTemplate<MyClass>::value 0219 0220 is a compile time boolean constant which is either 'true' or 'false' 0221 if the nested template exists. 0222 0223 @endcode 0224 0225 */ 0226 #define BOOST_TTI_HAS_TEMPLATE(...) \ 0227 BOOST_TTI_TRAIT_HAS_TEMPLATE \ 0228 ( \ 0229 BOOST_TTI_HAS_TEMPLATE_GEN \ 0230 ( \ 0231 BOOST_PP_VARIADIC_ELEM(0,__VA_ARGS__) \ 0232 ), \ 0233 __VA_ARGS__ \ 0234 ) \ 0235 /**/ 0236 0237 #else // !BOOST_PP_VARIADICS 0238 0239 #include <boost/preprocessor/detail/is_binary.hpp> 0240 #include <boost/tti/detail/dtemplate.hpp> 0241 #include <boost/tti/detail/dtemplate_params.hpp> 0242 0243 /// A macro which expands to a metafunction which tests whether an inner class template with a particular name exists. 0244 /** 0245 0246 BOOST_TTI_TRAIT_HAS_TEMPLATE is a macro which expands to a metafunction. 0247 The metafunction tests whether an inner class template with a particular name exists. 0248 The macro takes the form of BOOST_TTI_TRAIT_HAS_TEMPLATE(trait,name,params) where 0249 0250 trait = the name of the metafunction <br/> 0251 name = the inner class template name <br/> 0252 params = If the parameter is BOOST_PP_NIL the inner class template 0253 being introspected must be all template type parameters ( template parameters 0254 starting with `class` or `typename` ) and any number of template type parameters 0255 can occur. 0256 0257 If the parameter is a Boost preprocessor library array, then the inner class 0258 template must have its template parameters matching the sequence in the tuple portion 0259 of the Boost PP array. 0260 0261 If the parameter is anything else a compiler error occurs. 0262 0263 BOOST_TTI_TRAIT_HAS_TEMPLATE generates a metafunction called "trait" where 'trait' is the first macro parameter. 0264 0265 @code 0266 0267 template<class BOOST_TTI_TP_T> 0268 struct trait 0269 { 0270 static const value = unspecified; 0271 typedef mpl::bool_<true-or-false> type; 0272 }; 0273 0274 The metafunction types and return: 0275 0276 BOOST_TTI_TP_T = the enclosing type in which to look for our 'name'. 0277 The enclosing type can be a class, struct, or union. 0278 0279 returns = 'value' is true if the 'name' template exists within the enclosing type, 0280 otherwise 'value' is false. 0281 0282 @endcode 0283 0284 Examples: 0285 0286 @code 0287 0288 1) Search for an inner class template called 'MyTemplate', with all template type parameters, 0289 nested within the class 'MyClass' using a metafunction name of 'MyMeta'. 0290 0291 BOOST_TTI_TRAIT_HAS_TEMPLATE(MyMeta,MyTemplate,BOOST_PP_NIL) 0292 0293 MyMeta<MyClass>::value 0294 0295 is a compile time boolean constant which is either 'true' or 'false' 0296 if the nested template exists. 0297 0298 2) Search for an inner class template called 'MyTemplate', with template parameters 0299 of 'class T,int x,template<class> class U', nested within the class 'MyClass' 0300 using a metafunction name of 'MyMeta'. 0301 0302 BOOST_TTI_TRAIT_HAS_TEMPLATE(MyMeta,MyTemplate,(3,(class,int,template<class> class))) 0303 0304 MyMeta<MyClass>::value 0305 0306 is a compile time boolean constant which is either 'true' or 'false' 0307 if the nested template exists. 0308 0309 @endcode 0310 0311 */ 0312 #define BOOST_TTI_TRAIT_HAS_TEMPLATE(trait,name,params) \ 0313 BOOST_PP_IIF \ 0314 ( \ 0315 BOOST_PP_IS_BINARY(params), \ 0316 BOOST_TTI_DETAIL_TRAIT_HAS_TEMPLATE_CHECK_PARAMS, \ 0317 BOOST_TTI_DETAIL_TRAIT_CHECK_IS_NIL \ 0318 ) \ 0319 (trait,name,params) \ 0320 /**/ 0321 0322 /// A macro which expands to a metafunction which tests whether an inner class template with a particular name exists. 0323 /** 0324 0325 BOOST_TTI_HAS_TEMPLATE is a macro which expands to a metafunction. 0326 The metafunction tests whether an inner class template with a particular name exists. 0327 The macro takes the form of BOOST_TTI_HAS_TEMPLATE(name,params) where 0328 0329 name = the inner class template name <br/> 0330 params = If the parameter is BOOST_PP_NIL the inner class template 0331 being introspected must be all template type parameters ( template parameters 0332 starting with `class` or `typename` ) and any number of template type parameters 0333 can occur. 0334 0335 If the parameter is a Boost preprocessor library array, then the inner class 0336 template must have its template parameters matching the sequence in the tuple portion 0337 of the Boost PP array. 0338 0339 If the parameter is anything else a compiler error occurs. 0340 0341 BOOST_TTI_HAS_TEMPLATE generates a metafunction called "has_template_'name'" where 'name' is the first macro parameter. 0342 0343 @code 0344 0345 template<class BOOST_TTI_TP_T> 0346 struct has_template_'name' 0347 { 0348 static const value = unspecified; 0349 typedef mpl::bool_<true-or-false> type; 0350 }; 0351 0352 The metafunction types and return: 0353 0354 BOOST_TTI_TP_T = the enclosing type in which to look for our 'name'. 0355 The enclosing type can be a class, struct, or union. 0356 0357 returns = 'value' is true if the 'name' template exists within the enclosing type, 0358 otherwise 'value' is false. 0359 0360 @endcode 0361 0362 Examples: 0363 0364 @code 0365 0366 1) Search for an inner class template called 'MyTemplate', with all template type parameters, 0367 nested within the class 'MyClass'. 0368 0369 BOOST_TTI_HAS_TEMPLATE(MyTemplate,BOOST_PP_NIL) 0370 0371 has_template_MyTemplate<MyClass>::value 0372 0373 is a compile time boolean constant which is either 'true' or 'false' 0374 if the nested template exists. 0375 0376 2) Search for an inner class template called 'MyTemplate' with template parameters 0377 of 'class T,int x,template<class> class U' nested within the class 'MyClass'. 0378 0379 BOOST_TTI_HAS_TEMPLATE(MyTemplate,(3,(class,int,template<class> class))) 0380 0381 has_template_MyTemplate<MyClass>::value 0382 0383 is a compile time boolean constant which is either 'true' or 'false' 0384 if the nested template exists. 0385 0386 @endcode 0387 0388 */ 0389 #define BOOST_TTI_HAS_TEMPLATE(name,params) \ 0390 BOOST_TTI_TRAIT_HAS_TEMPLATE \ 0391 ( \ 0392 BOOST_TTI_HAS_TEMPLATE_GEN(name), \ 0393 name, \ 0394 params \ 0395 ) \ 0396 /**/ 0397 0398 #endif // BOOST_PP_VARIADICS 0399 #endif // BOOST_TTI_HAS_TEMPLATE_HPP
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |