has_static_member_data.hpp 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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_DATA_HPP)
  6. #define BOOST_TTI_HAS_STATIC_MEMBER_DATA_HPP
  7. #include <boost/config.hpp>
  8. #include <boost/preprocessor/cat.hpp>
  9. #include <boost/tti/gen/has_static_member_data_gen.hpp>
  10. #include <boost/tti/detail/dstatic_mem_data.hpp>
  11. /*
  12. The succeeding comments in this file are in doxygen format.
  13. */
  14. /** \file
  15. */
  16. /// Expands to a metafunction which tests whether a static member data with a particular name and type exists.
  17. /**
  18. trait = the name of the metafunction within the tti namespace.
  19. name = the name of the inner member.
  20. generates a metafunction called "trait" where 'trait' is the macro parameter.
  21. The metafunction types and return:
  22. BOOST_TTI_TP_T = the enclosing type.
  23. BOOST_TTI_TP_TYPE = the static member data type,
  24. in the form of a data type,
  25. in which to look for our 'name'.
  26. returns = 'value' is true if the 'name' exists,
  27. with the BOOST_TTI_TP_TYPE type,
  28. within the enclosing BOOST_TTI_TP_T type,
  29. otherwise 'value' is false.
  30. */
  31. #define BOOST_TTI_TRAIT_HAS_STATIC_MEMBER_DATA(trait,name) \
  32. BOOST_TTI_DETAIL_TRAIT_HAS_STATIC_MEMBER_DATA(trait,name) \
  33. template<class BOOST_TTI_TP_T,class BOOST_TTI_TP_TYPE> \
  34. struct trait \
  35. { \
  36. typedef typename \
  37. BOOST_PP_CAT(trait,_detail_hsd)<BOOST_TTI_TP_T,BOOST_TTI_TP_TYPE>::type type; \
  38. BOOST_STATIC_CONSTANT(bool,value=type::value); \
  39. }; \
  40. /**/
  41. /// Expands to a metafunction which tests whether a static member data with a particular name and type exists.
  42. /**
  43. name = the name of the inner member.
  44. generates a metafunction called "has_static_member_data_name" where 'name' is the macro parameter.
  45. The metafunction types and return:
  46. BOOST_TTI_TP_T = the enclosing type.
  47. BOOST_TTI_TP_TYPE = the static member data type,
  48. in the form of a data type,
  49. in which to look for our 'name'.
  50. returns = 'value' is true if the 'name' exists,
  51. with the appropriate BOOST_TTI_TP_TYPE type,
  52. within the enclosing BOOST_TTI_TP_T type,
  53. otherwise 'value' is false.
  54. */
  55. #define BOOST_TTI_HAS_STATIC_MEMBER_DATA(name) \
  56. BOOST_TTI_TRAIT_HAS_STATIC_MEMBER_DATA \
  57. ( \
  58. BOOST_TTI_HAS_STATIC_MEMBER_DATA_GEN(name), \
  59. name \
  60. ) \
  61. /**/
  62. #endif // BOOST_TTI_HAS_STATIC_MEMBER_DATA_HPP