has_member_function_template.hpp 14 KB

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