dstatic_mem_data.hpp 4.4 KB

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