1 2 // (C) Copyright Edward Diener 2011,2012,2013 3 // Use, modification and distribution are subject to the Boost Software License, 4 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at 5 // http://www.boost.org/LICENSE_1_0.txt). 6 7 #if !defined(BOOST_TTI_DETAIL_STATIC_MEM_DATA_HPP) 8 #define BOOST_TTI_DETAIL_STATIC_MEM_DATA_HPP 9 10 #include <boost/config.hpp> 11 #include <boost/function_types/is_function.hpp> 12 #include <boost/mpl/bool.hpp> 13 #include <boost/mpl/eval_if.hpp> 14 #include <boost/preprocessor/cat.hpp> 15 #include <boost/type_traits/is_class.hpp> 16 #include <boost/type_traits/detail/yes_no_type.hpp> 17 #include <boost/tti/detail/dnullptr.hpp> 18 19 #if defined(BOOST_MSVC) 20 21 #define BOOST_TTI_DETAIL_TRAIT_HAS_STATIC_MEMBER_DATA_OP(trait,name) \ 22 template<class BOOST_TTI_DETAIL_TP_T,class BOOST_TTI_DETAIL_TP_TYPE> \ 23 struct BOOST_PP_CAT(trait,_detail_hsd_op) \ 24 { \ 25 template<bool,typename BOOST_TTI_DETAIL_TP_U> \ 26 struct menable_if; \ 27 \ 28 template<typename BOOST_TTI_DETAIL_TP_U> \ 29 struct menable_if<true,BOOST_TTI_DETAIL_TP_U> \ 30 { \ 31 typedef BOOST_TTI_DETAIL_TP_U type; \ 32 }; \ 33 \ 34 template<typename BOOST_TTI_DETAIL_TP_U,typename BOOST_TTI_DETAIL_TP_V> \ 35 static ::boost::type_traits::yes_type check2(BOOST_TTI_DETAIL_TP_V *); \ 36 \ 37 template<typename BOOST_TTI_DETAIL_TP_U,typename BOOST_TTI_DETAIL_TP_V> \ 38 static ::boost::type_traits::no_type check2(BOOST_TTI_DETAIL_TP_U); \ 39 \ 40 template<typename BOOST_TTI_DETAIL_TP_U,typename BOOST_TTI_DETAIL_TP_V> \ 41 static typename \ 42 menable_if \ 43 < \ 44 sizeof(check2<BOOST_TTI_DETAIL_TP_U,BOOST_TTI_DETAIL_TP_V>(&BOOST_TTI_DETAIL_TP_U::name))==sizeof(::boost::type_traits::yes_type), \ 45 ::boost::type_traits::yes_type \ 46 > \ 47 ::type \ 48 has_matching_member(int); \ 49 \ 50 template<typename BOOST_TTI_DETAIL_TP_U,typename BOOST_TTI_DETAIL_TP_V> \ 51 static ::boost::type_traits::no_type has_matching_member(...); \ 52 \ 53 template<class BOOST_TTI_DETAIL_TP_U,class BOOST_TTI_DETAIL_TP_V> \ 54 struct ttc_sd \ 55 { \ 56 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; \ 57 }; \ 58 \ 59 typedef typename ttc_sd<BOOST_TTI_DETAIL_TP_TYPE,BOOST_TTI_DETAIL_TP_T>::type type; \ 60 }; \ 61 /**/ 62 63 #elif defined(__SUNPRO_CC) 64 65 #define BOOST_TTI_DETAIL_TRAIT_HAS_STATIC_MEMBER_DATA_OP(trait,name) \ 66 template<class BOOST_TTI_DETAIL_TP_T,class BOOST_TTI_DETAIL_TP_TYPE> \ 67 struct BOOST_PP_CAT(trait,_detail_hsd_op) \ 68 { \ 69 template<BOOST_TTI_DETAIL_TP_TYPE *> \ 70 struct helper {}; \ 71 \ 72 template<class BOOST_TTI_DETAIL_TP_U> \ 73 static ::boost::type_traits::yes_type chkt(helper<&BOOST_TTI_DETAIL_TP_U::name> *); \ 74 \ 75 template<class BOOST_TTI_DETAIL_TP_U> \ 76 static ::boost::type_traits::no_type chkt(...); \ 77 \ 78 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; \ 79 }; \ 80 /**/ 81 82 #else 83 84 #define BOOST_TTI_DETAIL_TRAIT_HAS_STATIC_MEMBER_DATA_OP(trait,name) \ 85 template<class BOOST_TTI_DETAIL_TP_T,class BOOST_TTI_DETAIL_TP_TYPE> \ 86 struct BOOST_PP_CAT(trait,_detail_hsd_op) \ 87 { \ 88 template<BOOST_TTI_DETAIL_TP_TYPE *> \ 89 struct helper; \ 90 \ 91 template<class BOOST_TTI_DETAIL_TP_U> \ 92 static ::boost::type_traits::yes_type chkt(helper<&BOOST_TTI_DETAIL_TP_U::name> *); \ 93 \ 94 template<class BOOST_TTI_DETAIL_TP_U> \ 95 static ::boost::type_traits::no_type chkt(...); \ 96 \ 97 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; \ 98 }; \ 99 /**/ 100 101 #endif // defined(BOOST_MSVC) 102 103 #define BOOST_TTI_DETAIL_TRAIT_HAS_STATIC_MEMBER_DATA(trait,name) \ 104 BOOST_TTI_DETAIL_TRAIT_HAS_STATIC_MEMBER_DATA_OP(trait,name) \ 105 template<class BOOST_TTI_DETAIL_TP_T,class BOOST_TTI_DETAIL_TP_TYPE> \ 106 struct BOOST_PP_CAT(trait,_detail_hsd) : \ 107 boost::mpl::eval_if \ 108 < \ 109 boost::is_class<BOOST_TTI_DETAIL_TP_T>, \ 110 BOOST_PP_CAT(trait,_detail_hsd_op)<BOOST_TTI_DETAIL_TP_T,BOOST_TTI_DETAIL_TP_TYPE>, \ 111 boost::mpl::false_ \ 112 > \ 113 { \ 114 }; \ 115 /**/ 116 117 #endif // BOOST_TTI_DETAIL_STATIC_MEM_DATA_HPP 118