dstatic_mem_data.hpp 3.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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/preprocessor/cat.hpp>
  11. #include <boost/type_traits/detail/yes_no_type.hpp>
  12. #include <boost/tti/detail/dnullptr.hpp>
  13. #if defined(BOOST_MSVC)
  14. #define BOOST_TTI_DETAIL_TRAIT_HAS_STATIC_MEMBER_DATA(trait,name) \
  15. template<class BOOST_TTI_DETAIL_TP_T,class BOOST_TTI_DETAIL_TP_TYPE> \
  16. struct BOOST_PP_CAT(trait,_detail_hsd) \
  17. { \
  18. template<bool,typename BOOST_TTI_DETAIL_TP_U> \
  19. struct menable_if; \
  20. \
  21. template<typename BOOST_TTI_DETAIL_TP_U> \
  22. struct menable_if<true,BOOST_TTI_DETAIL_TP_U> \
  23. { \
  24. typedef BOOST_TTI_DETAIL_TP_U type; \
  25. }; \
  26. \
  27. template<typename BOOST_TTI_DETAIL_TP_U,typename BOOST_TTI_DETAIL_TP_V> \
  28. static ::boost::type_traits::yes_type check2(BOOST_TTI_DETAIL_TP_V *); \
  29. \
  30. template<typename BOOST_TTI_DETAIL_TP_U,typename BOOST_TTI_DETAIL_TP_V> \
  31. static ::boost::type_traits::no_type check2(BOOST_TTI_DETAIL_TP_U); \
  32. \
  33. template<typename BOOST_TTI_DETAIL_TP_U,typename BOOST_TTI_DETAIL_TP_V> \
  34. static typename \
  35. menable_if \
  36. < \
  37. sizeof(check2<BOOST_TTI_DETAIL_TP_U,BOOST_TTI_DETAIL_TP_V>(&BOOST_TTI_DETAIL_TP_U::name))==sizeof(::boost::type_traits::yes_type), \
  38. ::boost::type_traits::yes_type \
  39. > \
  40. ::type \
  41. has_matching_member(int); \
  42. \
  43. template<typename BOOST_TTI_DETAIL_TP_U,typename BOOST_TTI_DETAIL_TP_V> \
  44. static ::boost::type_traits::no_type has_matching_member(...); \
  45. \
  46. template<class BOOST_TTI_DETAIL_TP_U,class BOOST_TTI_DETAIL_TP_V> \
  47. struct ttc_sd \
  48. { \
  49. 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; \
  50. }; \
  51. \
  52. typedef typename ttc_sd<BOOST_TTI_DETAIL_TP_TYPE,BOOST_TTI_DETAIL_TP_T>::type type; \
  53. \
  54. BOOST_STATIC_CONSTANT(bool,value=type::value); \
  55. }; \
  56. /**/
  57. #else // !defined(BOOST_MSVC)
  58. #define BOOST_TTI_DETAIL_TRAIT_HAS_STATIC_MEMBER_DATA(trait,name) \
  59. template<class BOOST_TTI_DETAIL_TP_T,class BOOST_TTI_DETAIL_TP_TYPE> \
  60. struct BOOST_PP_CAT(trait,_detail_hsd) \
  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. BOOST_STATIC_CONSTANT(bool,value=(!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))); \
  72. \
  73. typedef boost::mpl::bool_<value> type; \
  74. }; \
  75. /**/
  76. #endif // defined(BOOST_MSVC)
  77. #endif // BOOST_TTI_DETAIL_STATIC_MEM_DATA_HPP