dstatic_mem_data.hpp 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  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_DETAIL_STATIC_MEM_DATA_HPP)
  6. #define BOOST_TTI_DETAIL_STATIC_MEM_DATA_HPP
  7. #include <boost/config.hpp>
  8. #include <boost/function_types/is_function.hpp>
  9. #include <boost/mpl/bool.hpp>
  10. #include <boost/mpl/eval_if.hpp>
  11. #include <boost/preprocessor/cat.hpp>
  12. #include <boost/type_traits/is_class.hpp>
  13. #include <boost/type_traits/detail/yes_no_type.hpp>
  14. #include <boost/tti/detail/denclosing_type.hpp>
  15. #include <boost/tti/detail/dmacro_sunfix.hpp>
  16. #include <boost/tti/detail/dnullptr.hpp>
  17. #include <boost/tti/gen/namespace_gen.hpp>
  18. #if defined(BOOST_MSVC)
  19. #define BOOST_TTI_DETAIL_TRAIT_HAS_STATIC_MEMBER_DATA_OP(trait,name) \
  20. template<class BOOST_TTI_DETAIL_TP_T,class BOOST_TTI_DETAIL_TP_TYPE> \
  21. struct BOOST_PP_CAT(trait,_detail_hsd_op) \
  22. { \
  23. template<bool,typename BOOST_TTI_DETAIL_TP_U> \
  24. struct menable_if; \
  25. \
  26. template<typename BOOST_TTI_DETAIL_TP_U> \
  27. struct menable_if<true,BOOST_TTI_DETAIL_TP_U> \
  28. { \
  29. typedef BOOST_TTI_DETAIL_TP_U type; \
  30. }; \
  31. \
  32. template<typename BOOST_TTI_DETAIL_TP_U,typename BOOST_TTI_DETAIL_TP_V> \
  33. static ::boost::type_traits::yes_type check2(BOOST_TTI_DETAIL_TP_V *); \
  34. \
  35. template<typename BOOST_TTI_DETAIL_TP_U,typename BOOST_TTI_DETAIL_TP_V> \
  36. static ::boost::type_traits::no_type check2(BOOST_TTI_DETAIL_TP_U); \
  37. \
  38. template<typename BOOST_TTI_DETAIL_TP_U,typename BOOST_TTI_DETAIL_TP_V> \
  39. static typename \
  40. menable_if \
  41. < \
  42. sizeof(check2<BOOST_TTI_DETAIL_TP_U,BOOST_TTI_DETAIL_TP_V>(&BOOST_TTI_DETAIL_TP_U::name))==sizeof(::boost::type_traits::yes_type), \
  43. ::boost::type_traits::yes_type \
  44. > \
  45. ::type \
  46. has_matching_member(int); \
  47. \
  48. template<typename BOOST_TTI_DETAIL_TP_U,typename BOOST_TTI_DETAIL_TP_V> \
  49. static ::boost::type_traits::no_type has_matching_member(...); \
  50. \
  51. template<class BOOST_TTI_DETAIL_TP_U,class BOOST_TTI_DETAIL_TP_V> \
  52. struct ttc_sd \
  53. { \
  54. typedef boost::mpl::bool_<sizeof(has_matching_member<BOOST_TTI_DETAIL_TP_V,BOOST_TTI_DETAIL_TP_U>(0))==sizeof(::boost::type_traits::yes_type)> type; \
  55. }; \
  56. \
  57. typedef typename ttc_sd<BOOST_TTI_DETAIL_TP_TYPE,BOOST_TTI_DETAIL_TP_T>::type type; \
  58. }; \
  59. /**/
  60. #else
  61. #define BOOST_TTI_DETAIL_TRAIT_HAS_STATIC_MEMBER_DATA_OP(trait,name) \
  62. template<class BOOST_TTI_DETAIL_TP_T,class BOOST_TTI_DETAIL_TP_TYPE> \
  63. struct BOOST_PP_CAT(trait,_detail_hsd_op) \
  64. { \
  65. template<BOOST_TTI_DETAIL_TP_TYPE *> \
  66. struct helper BOOST_TTI_DETAIL_MACRO_SUNFIX ; \
  67. \
  68. template<class BOOST_TTI_DETAIL_TP_U> \
  69. static ::boost::type_traits::yes_type chkt(helper<&BOOST_TTI_DETAIL_TP_U::name> *); \
  70. \
  71. template<class BOOST_TTI_DETAIL_TP_U> \
  72. static ::boost::type_traits::no_type chkt(...); \
  73. \
  74. typedef boost::mpl::bool_<(!boost::function_types::is_function<BOOST_TTI_DETAIL_TP_TYPE>::value) && (sizeof(chkt<BOOST_TTI_DETAIL_TP_T>(BOOST_TTI_DETAIL_NULLPTR))==sizeof(::boost::type_traits::yes_type))> type; \
  75. }; \
  76. /**/
  77. #endif // defined(BOOST_MSVC)
  78. #if defined(BOOST_NO_CXX11_UNRESTRICTED_UNION)
  79. #define BOOST_TTI_DETAIL_TRAIT_HAS_STATIC_MEMBER_DATA(trait,name) \
  80. BOOST_TTI_DETAIL_TRAIT_HAS_STATIC_MEMBER_DATA_OP(trait,name) \
  81. template<class BOOST_TTI_DETAIL_TP_T,class BOOST_TTI_DETAIL_TP_TYPE> \
  82. struct BOOST_PP_CAT(trait,_detail_hsd) : \
  83. boost::mpl::eval_if \
  84. < \
  85. boost::is_class<BOOST_TTI_DETAIL_TP_T>, \
  86. BOOST_PP_CAT(trait,_detail_hsd_op)<BOOST_TTI_DETAIL_TP_T,BOOST_TTI_DETAIL_TP_TYPE>, \
  87. boost::mpl::false_ \
  88. > \
  89. { \
  90. }; \
  91. /**/
  92. #else
  93. #define BOOST_TTI_DETAIL_TRAIT_HAS_STATIC_MEMBER_DATA(trait,name) \
  94. BOOST_TTI_DETAIL_TRAIT_HAS_STATIC_MEMBER_DATA_OP(trait,name) \
  95. template<class BOOST_TTI_DETAIL_TP_T,class BOOST_TTI_DETAIL_TP_TYPE> \
  96. struct BOOST_PP_CAT(trait,_detail_hsd) : \
  97. boost::mpl::eval_if \
  98. < \
  99. BOOST_TTI_NAMESPACE::detail::enclosing_type<BOOST_TTI_DETAIL_TP_T>, \
  100. BOOST_PP_CAT(trait,_detail_hsd_op)<BOOST_TTI_DETAIL_TP_T,BOOST_TTI_DETAIL_TP_TYPE>, \
  101. boost::mpl::false_ \
  102. > \
  103. { \
  104. }; \
  105. /**/
  106. #endif
  107. #endif // BOOST_TTI_DETAIL_STATIC_MEM_DATA_HPP