has_static_member_data.hpp 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  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. /// A macro which expands to a metafunction which tests whether a static member data with a particular name and type exists.
  17. /**
  18. BOOST_TTI_TRAIT_HAS_STATIC_MEMBER_DATA is a macro which expands to a metafunction.
  19. The metafunction tests whether static member data with a particular
  20. name and type exists. The macro takes the form of BOOST_TTI_TRAIT_HAS_STATIC_MEMBER_DATA(trait,name) where
  21. trait = the name of the metafunction <br/>
  22. name = the name of the inner member.
  23. BOOST_TTI_TRAIT_HAS_STATIC_MEMBER_DATA generates a metafunction called "trait" where 'trait' is the macro parameter.
  24. @code
  25. template<class BOOST_TTI_TP_T,class BOOST_TTI_TP_TYPE>
  26. struct trait
  27. {
  28. static const value = unspecified;
  29. typedef mpl::bool_<true-or-false> type;
  30. };
  31. The metafunction types and return:
  32. BOOST_TTI_TP_T = the enclosing type.
  33. The enclosing type can be a class, struct, or union.
  34. If the type is a union, static member data can only
  35. be found if the C++11 unrestricted union is implemented
  36. by the compiler being used, since prior to C++11 a union
  37. could not have static data members.
  38. BOOST_TTI_TP_TYPE = the type of the static member data.
  39. returns = 'value' is true if the 'name' exists,
  40. with the BOOST_TTI_TP_TYPE type,
  41. within the enclosing BOOST_TTI_TP_T type,
  42. otherwise 'value' is false.
  43. @endcode
  44. */
  45. #define BOOST_TTI_TRAIT_HAS_STATIC_MEMBER_DATA(trait,name) \
  46. BOOST_TTI_DETAIL_TRAIT_HAS_STATIC_MEMBER_DATA(trait,name) \
  47. template<class BOOST_TTI_TP_T,class BOOST_TTI_TP_TYPE> \
  48. struct trait \
  49. { \
  50. typedef typename \
  51. BOOST_PP_CAT(trait,_detail_hsd)<BOOST_TTI_TP_T,BOOST_TTI_TP_TYPE>::type type; \
  52. BOOST_STATIC_CONSTANT(bool,value=type::value); \
  53. }; \
  54. /**/
  55. /// A macro which expands to a metafunction which tests whether a static member data with a particular name and type exists.
  56. /**
  57. BOOST_TTI_HAS_STATIC_MEMBER_DATA is a macro which expands to a metafunction.
  58. The metafunction tests whether static member data with a particular
  59. name and type exists. The macro takes the form of BOOST_TTI_HAS_STATIC_MEMBER_DATA(name) where
  60. name = the name of the inner member.
  61. BOOST_TTI_HAS_STATIC_MEMBER_DATA generates a metafunction called "has_static_member_data_name" where 'name' is the macro parameter.
  62. @code
  63. template<class BOOST_TTI_TP_T,class BOOST_TTI_TP_TYPE>
  64. struct has_static_member_data_'name'
  65. {
  66. static const value = unspecified;
  67. typedef mpl::bool_<true-or-false> type;
  68. };
  69. The metafunction types and return:
  70. BOOST_TTI_TP_T = the enclosing type.
  71. The enclosing type can be a class, struct, or union.
  72. If the type is a union, static member data can only
  73. be found if the C++11 unrestricted union is implemented
  74. by the compiler being used, since prior to C++11 a union
  75. could not have static data members.
  76. BOOST_TTI_TP_TYPE = the type of the static member data.
  77. returns = 'value' is true if the 'name' exists,
  78. with the appropriate BOOST_TTI_TP_TYPE type,
  79. within the enclosing BOOST_TTI_TP_T type,
  80. otherwise 'value' is false.
  81. @endcode
  82. */
  83. #define BOOST_TTI_HAS_STATIC_MEMBER_DATA(name) \
  84. BOOST_TTI_TRAIT_HAS_STATIC_MEMBER_DATA \
  85. ( \
  86. BOOST_TTI_HAS_STATIC_MEMBER_DATA_GEN(name), \
  87. name \
  88. ) \
  89. /**/
  90. #endif // BOOST_TTI_HAS_STATIC_MEMBER_DATA_HPP