has_member_data.hpp 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  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_MEMBER_DATA_HPP)
  6. #define BOOST_TTI_HAS_MEMBER_DATA_HPP
  7. #include <boost/config.hpp>
  8. #include <boost/preprocessor/cat.hpp>
  9. #include <boost/tti/detail/ddeftype.hpp>
  10. #include <boost/tti/detail/dmem_data.hpp>
  11. #include <boost/tti/gen/has_member_data_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 data with a particular name and type exists.
  18. /**
  19. trait = the name of the metafunction.
  20. name = the name of the inner member to introspect.
  21. generates a metafunction called "trait" where 'trait' is the macro parameter.
  22. template<class BOOST_TTI_TP_ET,class BOOST_TTI_TP_TYPE>
  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_ET = the enclosing type in which to look for our 'name'
  30. OR
  31. The type of the member data in the form of a pointer
  32. to member data.
  33. BOOST_TTI_TP_TYPE = (optional) The type of the member data if the first
  34. parameter is the enclosing type.
  35. returns = 'value' is true if the 'name' exists, with the correct data type,
  36. otherwise 'value' is false.
  37. */
  38. #define BOOST_TTI_TRAIT_HAS_MEMBER_DATA(trait,name) \
  39. BOOST_TTI_DETAIL_TRAIT_HAS_MEMBER_DATA(trait,name) \
  40. template<class BOOST_TTI_TP_ET,class BOOST_TTI_TP_TYPE = BOOST_TTI_NAMESPACE::detail::deftype> \
  41. struct trait \
  42. { \
  43. typedef typename \
  44. BOOST_PP_CAT(trait,_detail_hmd) \
  45. < \
  46. BOOST_TTI_TP_ET, \
  47. BOOST_TTI_TP_TYPE \
  48. >::type type; \
  49. BOOST_STATIC_CONSTANT(bool,value=type::value); \
  50. }; \
  51. /**/
  52. /// Expands to a metafunction which tests whether a member data with a particular name and type exists.
  53. /**
  54. name = the name of the inner member.
  55. generates a metafunction called "has_member_data_name" where 'name' is the macro parameter.
  56. template<class BOOST_TTI_TP_ET,class BOOST_TTI_TP_TYPE>
  57. struct has_member_data_name
  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_ET = the enclosing type in which to look for our 'name'
  64. OR
  65. The type of the member data in the form of a pointer
  66. to member data.
  67. BOOST_TTI_TP_TYPE = (optional) The type of the member data if the first
  68. parameter is the enclosing type.
  69. returns = 'value' is true if the 'name' exists, with the correct data type,
  70. otherwise 'value' is false.
  71. */
  72. #define BOOST_TTI_HAS_MEMBER_DATA(name) \
  73. BOOST_TTI_TRAIT_HAS_MEMBER_DATA \
  74. ( \
  75. BOOST_TTI_HAS_MEMBER_DATA_GEN(name), \
  76. name \
  77. ) \
  78. /**/
  79. #endif // BOOST_TTI_HAS_MEMBER_DATA_HPP