has_static_member_function.hpp 4.6 KB

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