has_static_member_function.hpp 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. // (C) Copyright Edward Diener 2011,2012,2013
  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_HAS_STATIC_MEMBER_FUNCTION_HPP)
  6. #define BOOST_TTI_HAS_STATIC_MEMBER_FUNCTION_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/dstatic_mem_fun.hpp>
  12. #include <boost/tti/gen/has_static_member_function_gen.hpp>
  13. /*
  14. The succeeding comments in this file are in doxygen format.
  15. */
  16. /** \file
  17. */
  18. /// A macro which expands to a metafunction which tests whether a static member function with a particular name and signature exists.
  19. /**
  20. BOOST_TTI_TRAIT_HAS_STATIC_MEMBER_FUNCTION is a macro which expands to a metafunction.
  21. The metafunction tests whether a static member function with a particular name
  22. and signature exists. The macro takes the form of BOOST_TTI_TRAIT_HAS_STATIC_MEMBER_FUNCTION(trait,name) where
  23. trait = the name of the metafunction <br/>
  24. name = the name of the inner member.
  25. BOOST_TTI_TRAIT_HAS_STATIC_MEMBER_FUNCTION generates a metafunction called "trait" where 'trait' is the macro parameter.
  26. @code
  27. template<class BOOST_TTI_TP_T,class BOOST_TTI_TP_R,class BOOST_TTI_TP_FS,class BOOST_TTI_TP_TAG>
  28. struct trait
  29. {
  30. static const value = unspecified;
  31. typedef mpl::bool_<true-or-false> type;
  32. };
  33. The metafunction types and return:
  34. BOOST_TTI_TP_T = the enclosing type in which to look for our 'name'.
  35. The enclosing type can be a class, struct, or union.
  36. BOOST_TTI_TP_R = the return type of the static member function
  37. OR
  38. the signature of a function in the form of Return_Type ( Parameter_Types )
  39. BOOST_TTI_TP_FS = (optional) the parameters of the static member function as a boost::mpl forward sequence
  40. if the second parameter is a return type and the function parameters exist.
  41. BOOST_TTI_TP_TAG = (optional) a boost::function_types tag to apply to the static member function
  42. if the second parameter is a return type and the need for a tag exists.
  43. returns = 'value' is true if the 'name' exists,
  44. with the appropriate static member function type,
  45. otherwise 'value' is false.
  46. @endcode
  47. */
  48. #define BOOST_TTI_TRAIT_HAS_STATIC_MEMBER_FUNCTION(trait,name) \
  49. BOOST_TTI_DETAIL_TRAIT_HAS_STATIC_MEMBER_FUNCTION(trait,name) \
  50. 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> \
  51. struct trait \
  52. { \
  53. typedef typename \
  54. BOOST_PP_CAT(trait,_detail_hsmf)<BOOST_TTI_TP_T,BOOST_TTI_TP_R,BOOST_TTI_TP_FS,BOOST_TTI_TP_TAG>::type type; \
  55. BOOST_STATIC_CONSTANT(bool,value=type::value); \
  56. }; \
  57. /**/
  58. /// A macro which expands to a metafunction which tests whether a static member function with a particular name and signature exists.
  59. /**
  60. BOOST_TTI_HAS_STATIC_MEMBER_FUNCTION is a macro which expands to a metafunction.
  61. The metafunction tests whether a static member function with a particular name
  62. and signature exists. The macro takes the form of BOOST_TTI_HAS_STATIC_MEMBER_FUNCTION(name) where
  63. name = the name of the inner member.
  64. BOOST_TTI_HAS_STATIC_MEMBER_FUNCTION generates a metafunction called "has_static_member_function_name" where 'name' is the macro parameter.
  65. @code
  66. template<class BOOST_TTI_TP_T,class BOOST_TTI_TP_R,class BOOST_TTI_TP_FS,class BOOST_TTI_TP_TAG>
  67. struct has_static_member_function_'name'
  68. {
  69. static const value = unspecified;
  70. typedef mpl::bool_<true-or-false> type;
  71. };
  72. The metafunction types and return:
  73. BOOST_TTI_TP_T = the enclosing type in which to look for our 'name'.
  74. The enclosing type can be a class, struct, or union.
  75. BOOST_TTI_TP_R = the return type of the static member function
  76. OR
  77. the signature of a function in the form of Return_Type ( Parameter_Types )
  78. BOOST_TTI_TP_FS = (optional) the parameters of the static member function as a boost::mpl forward sequence
  79. if the second parameter is a return type and the function parameters exist.
  80. BOOST_TTI_TP_TAG = (optional) a boost::function_types tag to apply to the static member function
  81. if the second parameter is a return type and the need for a tag exists.
  82. returns = 'value' is true if the 'name' exists,
  83. with the appropriate static member function type,
  84. otherwise 'value' is false.
  85. @endcode
  86. */
  87. #define BOOST_TTI_HAS_STATIC_MEMBER_FUNCTION(name) \
  88. BOOST_TTI_TRAIT_HAS_STATIC_MEMBER_FUNCTION \
  89. ( \
  90. BOOST_TTI_HAS_STATIC_MEMBER_FUNCTION_GEN(name), \
  91. name \
  92. ) \
  93. /**/
  94. #endif // BOOST_TTI_HAS_STATIC_MEMBER_FUNCTION_HPP