has_member_data.hpp 3.8 KB

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