has_function.hpp 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. // (C) Copyright Edward Diener 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_FUNCTION_HPP)
  6. #define BOOST_TTI_HAS_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/dfunction.hpp>
  11. #include <boost/tti/gen/has_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 member function or 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 function
  31. BOOST_TTI_TP_FS = (optional) the parameters of the function as a boost::mpl forward sequence
  32. if function parameters are not empty.
  33. BOOST_TTI_TP_TAG = (optional) a boost::function_types tag to apply to the function
  34. if the need for a tag exists.
  35. returns = 'value' is true if the 'name' exists,
  36. with the appropriate static member function type,
  37. otherwise 'value' is false.
  38. */
  39. #define BOOST_TTI_TRAIT_HAS_FUNCTION(trait,name) \
  40. BOOST_TTI_DETAIL_TRAIT_HAS_FUNCTION(trait,name) \
  41. 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> \
  42. struct trait : \
  43. BOOST_PP_CAT(trait,_detail_hf)<BOOST_TTI_TP_T,BOOST_TTI_TP_R,BOOST_TTI_TP_FS,BOOST_TTI_TP_TAG> \
  44. { \
  45. }; \
  46. /**/
  47. /// Expands to a metafunction which tests whether a member function or a static member function with a particular name and signature exists.
  48. /**
  49. name = the name of the inner member.
  50. generates a metafunction called "has_function_name" where 'name' is the macro parameter.
  51. template<class BOOST_TTI_TP_T,class BOOST_TTI_TP_R,class BOOST_TTI_TP_FS,class BOOST_TTI_TP_TAG>
  52. struct trait
  53. {
  54. static const value = unspecified;
  55. typedef mpl::bool_<true-or-false> type;
  56. };
  57. The metafunction types and return:
  58. BOOST_TTI_TP_T = the enclosing type in which to look for our 'name'.
  59. BOOST_TTI_TP_R = the return type of the function
  60. BOOST_TTI_TP_FS = (optional) the parameters of the function as a boost::mpl forward sequence
  61. if function parameters are not empty.
  62. BOOST_TTI_TP_TAG = (optional) a boost::function_types tag to apply to the function
  63. if the need for a tag exists.
  64. returns = 'value' is true if the 'name' exists,
  65. with the appropriate function type,
  66. otherwise 'value' is false.
  67. */
  68. #define BOOST_TTI_HAS_FUNCTION(name) \
  69. BOOST_TTI_TRAIT_HAS_FUNCTION \
  70. ( \
  71. BOOST_TTI_HAS_FUNCTION_GEN(name), \
  72. name \
  73. ) \
  74. /**/
  75. #endif // BOOST_TTI_HAS_FUNCTION_HPP