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).
7 #if !defined(BOOST_TTI_DETAIL_STATIC_MEM_DATA_HPP)
8 #define BOOST_TTI_DETAIL_STATIC_MEM_DATA_HPP
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/denclosing_type.hpp>
18 #include <boost/tti/detail/dmacro_sunfix.hpp>
19 #include <boost/tti/detail/dnullptr.hpp>
20 #include <boost/tti/gen/namespace_gen.hpp>
22 #if defined(BOOST_MSVC)
24 #define BOOST_TTI_DETAIL_TRAIT_HAS_STATIC_MEMBER_DATA_OP(trait,name) \
25 template<class BOOST_TTI_DETAIL_TP_T,class BOOST_TTI_DETAIL_TP_TYPE> \
26 struct BOOST_PP_CAT(trait,_detail_hsd_op) \
28 template<bool,typename BOOST_TTI_DETAIL_TP_U> \
31 template<typename BOOST_TTI_DETAIL_TP_U> \
32 struct menable_if<true,BOOST_TTI_DETAIL_TP_U> \
34 typedef BOOST_TTI_DETAIL_TP_U type; \
37 template<typename BOOST_TTI_DETAIL_TP_U,typename BOOST_TTI_DETAIL_TP_V> \
38 static ::boost::type_traits::yes_type check2(BOOST_TTI_DETAIL_TP_V *); \
40 template<typename BOOST_TTI_DETAIL_TP_U,typename BOOST_TTI_DETAIL_TP_V> \
41 static ::boost::type_traits::no_type check2(BOOST_TTI_DETAIL_TP_U); \
43 template<typename BOOST_TTI_DETAIL_TP_U,typename BOOST_TTI_DETAIL_TP_V> \
47 sizeof(check2<BOOST_TTI_DETAIL_TP_U,BOOST_TTI_DETAIL_TP_V>(&BOOST_TTI_DETAIL_TP_U::name))==sizeof(::boost::type_traits::yes_type), \
48 ::boost::type_traits::yes_type \
51 has_matching_member(int); \
53 template<typename BOOST_TTI_DETAIL_TP_U,typename BOOST_TTI_DETAIL_TP_V> \
54 static ::boost::type_traits::no_type has_matching_member(...); \
56 template<class BOOST_TTI_DETAIL_TP_U,class BOOST_TTI_DETAIL_TP_V> \
59 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; \
62 typedef typename ttc_sd<BOOST_TTI_DETAIL_TP_TYPE,BOOST_TTI_DETAIL_TP_T>::type type; \
68 #define BOOST_TTI_DETAIL_TRAIT_HAS_STATIC_MEMBER_DATA_OP(trait,name) \
69 template<class BOOST_TTI_DETAIL_TP_T,class BOOST_TTI_DETAIL_TP_TYPE> \
70 struct BOOST_PP_CAT(trait,_detail_hsd_op) \
72 template<BOOST_TTI_DETAIL_TP_TYPE *> \
73 struct helper BOOST_TTI_DETAIL_MACRO_SUNFIX ; \
75 template<class BOOST_TTI_DETAIL_TP_U> \
76 static ::boost::type_traits::yes_type chkt(helper<&BOOST_TTI_DETAIL_TP_U::name> *); \
78 template<class BOOST_TTI_DETAIL_TP_U> \
79 static ::boost::type_traits::no_type chkt(...); \
81 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; \
85 #endif // defined(BOOST_MSVC)
87 #if defined(BOOST_NO_CXX11_UNRESTRICTED_UNION)
89 #define BOOST_TTI_DETAIL_TRAIT_HAS_STATIC_MEMBER_DATA(trait,name) \
90 BOOST_TTI_DETAIL_TRAIT_HAS_STATIC_MEMBER_DATA_OP(trait,name) \
91 template<class BOOST_TTI_DETAIL_TP_T,class BOOST_TTI_DETAIL_TP_TYPE> \
92 struct BOOST_PP_CAT(trait,_detail_hsd) : \
95 boost::is_class<BOOST_TTI_DETAIL_TP_T>, \
96 BOOST_PP_CAT(trait,_detail_hsd_op)<BOOST_TTI_DETAIL_TP_T,BOOST_TTI_DETAIL_TP_TYPE>, \
105 #define BOOST_TTI_DETAIL_TRAIT_HAS_STATIC_MEMBER_DATA(trait,name) \
106 BOOST_TTI_DETAIL_TRAIT_HAS_STATIC_MEMBER_DATA_OP(trait,name) \
107 template<class BOOST_TTI_DETAIL_TP_T,class BOOST_TTI_DETAIL_TP_TYPE> \
108 struct BOOST_PP_CAT(trait,_detail_hsd) : \
109 boost::mpl::eval_if \
111 BOOST_TTI_NAMESPACE::detail::enclosing_type<BOOST_TTI_DETAIL_TP_T>, \
112 BOOST_PP_CAT(trait,_detail_hsd_op)<BOOST_TTI_DETAIL_TP_T,BOOST_TTI_DETAIL_TP_TYPE>, \
121 #endif // BOOST_TTI_DETAIL_STATIC_MEM_DATA_HPP