has_static_member_function_template.hpp 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306
  1. // (C) Copyright Edward Diener 2019
  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_STATIC_MEM_FUN_TEMPLATE_HPP)
  6. #define BOOST_TTI_STATIC_MEM_FUN_TEMPLATE_HPP
  7. #include <boost/config.hpp>
  8. #include <boost/function_types/property_tags.hpp>
  9. #include <boost/mpl/vector.hpp>
  10. #include <boost/preprocessor/cat.hpp>
  11. #include <boost/tti/gen/namespace_gen.hpp>
  12. #include <boost/tti/gen/has_static_member_function_template_gen.hpp>
  13. #include <boost/tti/detail/dstatic_mem_fun_template.hpp>
  14. #if BOOST_PP_VARIADICS
  15. #include <boost/tti/detail/dmacro_fun_template.hpp>
  16. /*
  17. The succeeding comments in this file are in doxygen format.
  18. */
  19. /** \file
  20. */
  21. /// A macro which expands to a metafunction which tests whether an inner static member function template with a particular name exists.
  22. /**
  23. BOOST_TTI_TRAIT_HAS_STATIC_MEMBER_FUNCTION_TEMPLATE is a macro which expands to a metafunction.
  24. The metafunction tests whether an inner static member function template with a particular name exists.
  25. The macro takes the form of BOOST_TTI_TRAIT_HAS_STATIC_MEMBER_FUNCTION_TEMPLATE(trait,name,...) where
  26. trait = the name of the metafunction <br/>
  27. name = inner static member function template name <br/>
  28. ... = variadic parameters.
  29. The variadic parameter(s) are either:
  30. A sequence of valid instantiations for the static member function template parameters
  31. ie. 'int,long,double' etc.
  32. or
  33. A single variadic parameter which is a Boost PP array whose elements are
  34. a sequence of valid instantiations for the static member function template parameters
  35. ie. '(3,(int,long,double))' etc. This form is allowed in order to be compatible
  36. with using the non-variadic form of this macro.
  37. BOOST_TTI_TRAIT_HAS_STATIC_MEMBER_FUNCTION_TEMPLATE generates a metafunction called "trait" where 'trait' is the first macro parameter.
  38. @code
  39. template<class BOOST_TTI_TP_T,class BOOST_TTI_R,class BOOST_TTI_FS,class BOOST_TTI_TAG>
  40. struct trait
  41. {
  42. static const value = unspecified;
  43. typedef mpl::bool_<true-or-false> type;
  44. };
  45. The metafunction types and return:
  46. BOOST_TTI_TP_T = the enclosing type in which to look for our 'name'.
  47. The enclosing type can be a class, struct, or union.
  48. BOOST_TTI_TP_R = the return type of the static member function template
  49. in a single instantiation of the static member function template
  50. OR
  51. a pointer to function as a single type
  52. which encapsulates a single instantiation of
  53. the static member function template.
  54. BOOST_TTI_TP_FS = (optional) the parameters of the static member function template as a boost::mpl forward sequence
  55. if the second parameter is the enclosing type and the static member function template parameters
  56. are not empty. These parameters are a single instantiation of the static member function template.
  57. BOOST_TTI_TP_TAG = (optional) a boost::function_types tag to apply to the static member function template
  58. if the second parameter is the enclosing type and a tag is needed.
  59. returns = 'value' is true if the 'name' exists,
  60. with the appropriate static member function template type,
  61. otherwise 'value' is false.
  62. @endcode
  63. */
  64. #define BOOST_TTI_TRAIT_HAS_STATIC_MEMBER_FUNCTION_TEMPLATE(trait,name,...) \
  65. BOOST_TTI_DETAIL_TRAIT_HAS_STATIC_MEMBER_FUNCTION_TEMPLATE \
  66. ( \
  67. trait, \
  68. name, \
  69. BOOST_TTI_DETAIL_FUN_TEMPLATE_VARIADIC_TO_ARRAY(__VA_ARGS__) \
  70. ) \
  71. template<class BOOST_TTI_TP_T,class BOOST_TTI_TP_R,class BOOST_TTI_TP_FS = boost::mpl::vector<>,class BOOST_TTI_TP_TAG = boost::function_types::null_tag> \
  72. struct trait \
  73. { \
  74. typedef typename \
  75. BOOST_PP_CAT(trait,_detail_hsmft)<BOOST_TTI_TP_T,BOOST_TTI_TP_R,BOOST_TTI_TP_FS,BOOST_TTI_TP_TAG>::type type; \
  76. BOOST_STATIC_CONSTANT(bool,value=type::value); \
  77. }; \
  78. /**/
  79. /// A macro which expands to a metafunction which tests whether an inner static member function template with a particular name exists.
  80. /**
  81. BOOST_TTI_HAS_STATIC_MEMBER_FUNCTION_TEMPLATE is a macro which expands to a metafunction.
  82. The metafunction tests whether an inner static member function template with a particular name exists.
  83. The macro takes the form of BOOST_TTI_HAS_STATIC_MEMBER_FUNCTION_TEMPLATE(name,...) where
  84. name = inner static member function template name <br/>
  85. ... = variadic parameters.
  86. The variadic parameter(s) are either:
  87. A sequence of valid instantiations for the static member function template parameters
  88. ie. 'int,long,double' etc.
  89. or
  90. A single variadic parameter which is a Boost PP array whose elements are
  91. a sequence of valid instantiations for the static member function template parameters
  92. ie. '(3,(int,long,double))' etc. This form is allowed in order to be compatible
  93. with using the non-variadic form of this macro.
  94. BOOST_TTI_HAS_STATIC_MEMBER_FUNCTION_TEMPLATE generates a metafunction called "has_static_member_function_template_'name'" where 'name' is the first macro parameter.
  95. @code
  96. template<class BOOST_TTI_TP_T,class BOOST_TTI_R,class BOOST_TTI_FS,class BOOST_TTI_TAG>
  97. struct has_static_member_function_template_'name'
  98. {
  99. static const value = unspecified;
  100. typedef mpl::bool_<true-or-false> type;
  101. };
  102. The metafunction types and return:
  103. BOOST_TTI_TP_T = the enclosing type in which to look for our 'name'.
  104. The enclosing type can be a class, struct, or union.
  105. BOOST_TTI_TP_R = the return type of the static member function template
  106. in a single instantiation of the static member function template
  107. OR
  108. a pointer to function as a single type
  109. which encapsulates a single instantiation of
  110. the static member function template.
  111. BOOST_TTI_TP_FS = (optional) the parameters of the static member function template as a boost::mpl forward sequence
  112. if the second parameter is the enclosing type and the static member function template parameters
  113. are not empty. These parameters are a single instantiation of the static member function template.
  114. BOOST_TTI_TP_TAG = (optional) a boost::function_types tag to apply to the static member function template
  115. if the second parameter is the enclosing type and a tag is needed.
  116. returns = 'value' is true if the 'name' exists,
  117. with the appropriate static member function template type,
  118. otherwise 'value' is false.
  119. @endcode
  120. */
  121. #define BOOST_TTI_HAS_STATIC_MEMBER_FUNCTION_TEMPLATE(name,...) \
  122. BOOST_TTI_TRAIT_HAS_STATIC_MEMBER_FUNCTION_TEMPLATE \
  123. ( \
  124. BOOST_TTI_HAS_STATIC_MEMBER_FUNCTION_TEMPLATE_GEN(name), \
  125. name, \
  126. __VA_ARGS__ \
  127. ) \
  128. /**/
  129. #else // !BOOST_PP_VARIADICS
  130. /*
  131. The succeeding comments in this file are in doxygen format.
  132. */
  133. /** \file
  134. */
  135. /// A macro which expands to a metafunction which tests whether an inner static member function template with a particular name exists.
  136. /**
  137. BOOST_TTI_TRAIT_HAS_STATIC_MEMBER_FUNCTION_TEMPLATE is a macro which expands to a metafunction.
  138. The metafunction tests whether an inner static member function template with a particular name exists.
  139. The macro takes the form of BOOST_TTI_TRAIT_HAS_STATIC_MEMBER_FUNCTION_TEMPLATE(trait,name,pparray) where
  140. trait = the name of the metafunction <br/>
  141. name = inner static member function template name <br/>
  142. pparray = a Boost PP array whose elements are a sequence of valid instantiations for
  143. the static member function template parameters ie. '(3,(int,long,double))' etc.
  144. BOOST_TTI_TRAIT_HAS_STATIC_MEMBER_FUNCTION_TEMPLATE generates a metafunction called "trait" where 'trait' is the first macro parameter.
  145. @code
  146. template<class BOOST_TTI_TP_T,class BOOST_TTI_R,class BOOST_TTI_FS,class BOOST_TTI_TAG>
  147. struct trait
  148. {
  149. static const value = unspecified;
  150. typedef mpl::bool_<true-or-false> type;
  151. };
  152. The metafunction types and return:
  153. BOOST_TTI_TP_T = the enclosing type in which to look for our 'name'.
  154. The enclosing type can be a class, struct, or union.
  155. BOOST_TTI_TP_R = the return type of the static member function template
  156. in a single instantiation of the static member function template
  157. OR
  158. a pointer to function as a single type
  159. which encapsulates a single instantiation of
  160. the static member function template.
  161. BOOST_TTI_TP_FS = (optional) the parameters of the static member function template as a boost::mpl forward sequence
  162. if the second parameter is the enclosing type and the static member function template parameters
  163. are not empty. These parameters are a single instantiation of the static member function template.
  164. BOOST_TTI_TP_TAG = (optional) a boost::function_types tag to apply to the static member function template
  165. if the second parameter is the enclosing type and a tag is needed.
  166. returns = 'value' is true if the 'name' exists,
  167. with the appropriate static member function template type,
  168. otherwise 'value' is false.
  169. @endcode
  170. */
  171. #define BOOST_TTI_TRAIT_HAS_STATIC_MEMBER_FUNCTION_TEMPLATE(trait,name,pparray) \
  172. BOOST_TTI_DETAIL_TRAIT_HAS_STATIC_MEMBER_FUNCTION_TEMPLATE(trait,name,pparray) \
  173. template<class BOOST_TTI_TP_T,class BOOST_TTI_TP_R,class BOOST_TTI_TP_FS = boost::mpl::vector<>,class BOOST_TTI_TP_TAG = boost::function_types::null_tag> \
  174. struct trait \
  175. { \
  176. typedef typename \
  177. BOOST_PP_CAT(trait,_detail_hsmft)<BOOST_TTI_TP_T,BOOST_TTI_TP_R,BOOST_TTI_TP_FS,BOOST_TTI_TP_TAG>::type type; \
  178. BOOST_STATIC_CONSTANT(bool,value=type::value); \
  179. }; \
  180. /**/
  181. /// A macro which expands to a metafunction which tests whether an inner static member function template with a particular name exists.
  182. /**
  183. BOOST_TTI_HAS_STATIC_MEMBER_FUNCTION_TEMPLATE is a macro which expands to a metafunction.
  184. The metafunction tests whether an inner static member function template with a particular name exists.
  185. The macro takes the form of BOOST_TTI_HAS_STATIC_MEMBER_FUNCTION_TEMPLATE(name,pparray) where
  186. name = inner static member function template name <br/>
  187. pparray = a Boost PP array whose elements are a sequence of valid instantiations for
  188. the static member function template parameters ie. '(3,(int,long,double))' etc.
  189. BOOST_TTI_HAS_STATIC_MEMBER_FUNCTION_TEMPLATE generates a metafunction called "has_static_member_function_template_'name'" where 'name' is the first macro parameter.
  190. @code
  191. template<class BOOST_TTI_TP_T,class BOOST_TTI_R,class BOOST_TTI_FS,class BOOST_TTI_TAG>
  192. struct has_static_member_function_template_'name'
  193. {
  194. static const value = unspecified;
  195. typedef mpl::bool_<true-or-false> type;
  196. };
  197. The metafunction types and return:
  198. BOOST_TTI_TP_T = the enclosing type in which to look for our 'name'.
  199. The enclosing type can be a class, struct, or union.
  200. BOOST_TTI_TP_R = the return type of the static member function template
  201. in a single instantiation of the static member function template
  202. OR
  203. a pointer to function as a single type
  204. which encapsulates a single instantiation of
  205. the static member function template.
  206. BOOST_TTI_TP_FS = (optional) the parameters of the static member function template as a boost::mpl forward sequence
  207. if the second parameter is the enclosing type and the static member function template parameters
  208. are not empty. These parameters are a single instantiation of the static member function template.
  209. BOOST_TTI_TP_TAG = (optional) a boost::function_types tag to apply to the static member function template
  210. if the second parameter is the enclosing type and a tag is needed.
  211. returns = 'value' is true if the 'name' exists,
  212. with the appropriate static member function template type,
  213. otherwise 'value' is false.
  214. @endcode
  215. */
  216. #define BOOST_TTI_HAS_STATIC_MEMBER_FUNCTION_TEMPLATE(name,pparray) \
  217. BOOST_TTI_TRAIT_HAS_STATIC_MEMBER_FUNCTION_TEMPLATE \
  218. ( \
  219. BOOST_TTI_HAS_STATIC_MEMBER_FUNCTION_TEMPLATE_GEN(name), \
  220. name, \
  221. pparray \
  222. ) \
  223. /**/
  224. #endif // BOOST_PP_VARIADICS
  225. #endif // BOOST_TTI_STATIC_MEM_FUN_TEMPLATE_HPP