has_static_member_function.hpp 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  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. /// Expands to a metafunction which tests whether a static member function with a particular name and signature exists.
  19. /**
  20. trait = the name of the metafunction within the tti namespace.
  21. name = the name of the inner member.
  22. generates a metafunction called "trait" where 'trait' is the macro parameter.
  23. template<class BOOST_TTI_TP_T,class BOOST_TTI_TP_R,class BOOST_TTI_TP_FS,class BOOST_TTI_TP_TAG>
  24. struct trait
  25. {
  26. static const value = unspecified;
  27. typedef mpl::bool_<true-or-false> type;
  28. };
  29. The metafunction types and return:
  30. BOOST_TTI_TP_T = the enclosing type in which to look for our 'name'.
  31. BOOST_TTI_TP_R = the return type of the static member function
  32. OR
  33. the signature of a function in the form of Return_Type ( Parameter_Types )
  34. BOOST_TTI_TP_FS = (optional) the parameters of the static member function as a boost::mpl forward sequence
  35. if the second parameter is a return type and the function parameters exist.
  36. BOOST_TTI_TP_TAG = (optional) a boost::function_types tag to apply to the static member function
  37. if the second parameter is a return type and the need for a tag exists.
  38. returns = 'value' is true if the 'name' exists,
  39. with the appropriate static member function type,
  40. otherwise 'value' is false.
  41. */
  42. #define BOOST_TTI_TRAIT_HAS_STATIC_MEMBER_FUNCTION(trait,name) \
  43. BOOST_TTI_DETAIL_TRAIT_HAS_STATIC_MEMBER_FUNCTION(trait,name) \
  44. 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> \
  45. struct trait \
  46. { \
  47. typedef typename \
  48. BOOST_PP_CAT(trait,_detail_hsmf)<BOOST_TTI_TP_T,BOOST_TTI_TP_R,BOOST_TTI_TP_FS,BOOST_TTI_TP_TAG>::type type; \
  49. BOOST_STATIC_CONSTANT(bool,value=type::value); \
  50. }; \
  51. /**/
  52. /// Expands to a metafunction which tests whether a static member function with a particular name and signature exists.
  53. /**
  54. name = the name of the inner member.
  55. generates a metafunction called "has_static_member_function_name" where 'name' is the macro parameter.
  56. template<class BOOST_TTI_TP_T,class BOOST_TTI_TP_R,class BOOST_TTI_TP_FS,class BOOST_TTI_TP_TAG>
  57. struct trait
  58. {
  59. static const value = unspecified;
  60. typedef mpl::bool_<true-or-false> type;
  61. };
  62. The metafunction types and return:
  63. BOOST_TTI_TP_T = the enclosing type in which to look for our 'name'.
  64. BOOST_TTI_TP_R = the return type of the static member function
  65. OR
  66. the signature of a function in the form of Return_Type ( Parameter_Types )
  67. BOOST_TTI_TP_FS = (optional) the parameters of the static member function as a boost::mpl forward sequence
  68. if the second parameter is a return type and the function parameters exist.
  69. BOOST_TTI_TP_TAG = (optional) a boost::function_types tag to apply to the static member function
  70. if the second parameter is a return type and the need for a tag exists.
  71. returns = 'value' is true if the 'name' exists,
  72. with the appropriate static member function type,
  73. otherwise 'value' is false.
  74. */
  75. #define BOOST_TTI_HAS_STATIC_MEMBER_FUNCTION(name) \
  76. BOOST_TTI_TRAIT_HAS_STATIC_MEMBER_FUNCTION \
  77. ( \
  78. BOOST_TTI_HAS_STATIC_MEMBER_FUNCTION_GEN(name), \
  79. name \
  80. ) \
  81. /**/
  82. #endif // BOOST_TTI_HAS_STATIC_MEMBER_FUNCTION_HPP