]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
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_MEM_DATA_HPP) | |
8 | #define BOOST_TTI_DETAIL_MEM_DATA_HPP | |
9 | ||
10 | #include <boost/config.hpp> | |
11 | #include <boost/detail/workaround.hpp> | |
12 | #include <boost/function_types/components.hpp> | |
13 | #include <boost/function_types/is_member_object_pointer.hpp> | |
14 | #include <boost/mpl/assert.hpp> | |
15 | #include <boost/mpl/bool.hpp> | |
16 | #include <boost/mpl/eval_if.hpp> | |
17 | #include <boost/mpl/identity.hpp> | |
18 | #include <boost/mpl/or.hpp> | |
19 | #include <boost/preprocessor/cat.hpp> | |
20 | #include <boost/tti/detail/ddeftype.hpp> | |
21 | #include <boost/tti/detail/dftclass.hpp> | |
22 | #include <boost/tti/gen/namespace_gen.hpp> | |
23 | #include <boost/type_traits/detail/yes_no_type.hpp> | |
24 | #include <boost/type_traits/is_class.hpp> | |
25 | #include <boost/type_traits/is_same.hpp> | |
26 | #include <boost/type_traits/remove_const.hpp> | |
27 | ||
28 | #if defined(BOOST_MSVC) || (BOOST_WORKAROUND(BOOST_GCC, >= 40400) && BOOST_WORKAROUND(BOOST_GCC, < 40600)) | |
29 | ||
30 | #define BOOST_TTI_DETAIL_TRAIT_HAS_MEMBER_DATA_OP(trait,name) \ | |
31 | template<class BOOST_TTI_DETAIL_TP_T,class BOOST_TTI_DETAIL_TP_C> \ | |
32 | struct BOOST_PP_CAT(trait,_detail_hmd_op) \ | |
33 | { \ | |
34 | template<class> \ | |
35 | struct return_of; \ | |
36 | \ | |
37 | template<class BOOST_TTI_DETAIL_TP_R,class BOOST_TTI_DETAIL_TP_IC> \ | |
38 | struct return_of<BOOST_TTI_DETAIL_TP_R BOOST_TTI_DETAIL_TP_IC::*> \ | |
39 | { \ | |
40 | typedef BOOST_TTI_DETAIL_TP_R type; \ | |
41 | }; \ | |
42 | \ | |
43 | template<bool,typename BOOST_TTI_DETAIL_TP_U> \ | |
44 | struct menable_if; \ | |
45 | \ | |
46 | template<typename BOOST_TTI_DETAIL_TP_U> \ | |
47 | struct menable_if<true,BOOST_TTI_DETAIL_TP_U> \ | |
48 | { \ | |
49 | typedef BOOST_TTI_DETAIL_TP_U type; \ | |
50 | }; \ | |
51 | \ | |
52 | template<typename BOOST_TTI_DETAIL_TP_U,typename BOOST_TTI_DETAIL_TP_V> \ | |
53 | static ::boost::type_traits::yes_type check2(BOOST_TTI_DETAIL_TP_V BOOST_TTI_DETAIL_TP_U::*); \ | |
54 | \ | |
55 | template<typename BOOST_TTI_DETAIL_TP_U,typename BOOST_TTI_DETAIL_TP_V> \ | |
56 | static ::boost::type_traits::no_type check2(BOOST_TTI_DETAIL_TP_U); \ | |
57 | \ | |
58 | template<typename BOOST_TTI_DETAIL_TP_U,typename BOOST_TTI_DETAIL_TP_V> \ | |
59 | static typename \ | |
60 | menable_if \ | |
61 | < \ | |
62 | sizeof(check2<BOOST_TTI_DETAIL_TP_U,BOOST_TTI_DETAIL_TP_V>(&BOOST_TTI_DETAIL_TP_U::name))==sizeof(::boost::type_traits::yes_type), \ | |
63 | ::boost::type_traits::yes_type \ | |
64 | > \ | |
65 | ::type \ | |
66 | has_matching_member(int); \ | |
67 | \ | |
68 | template<typename BOOST_TTI_DETAIL_TP_U,typename BOOST_TTI_DETAIL_TP_V> \ | |
69 | static ::boost::type_traits::no_type has_matching_member(...); \ | |
70 | \ | |
71 | template<class BOOST_TTI_DETAIL_TP_U,class BOOST_TTI_DETAIL_TP_V> \ | |
72 | struct ttc_md \ | |
73 | { \ | |
74 | typedef boost::mpl::bool_<sizeof(has_matching_member<BOOST_TTI_DETAIL_TP_V,typename return_of<BOOST_TTI_DETAIL_TP_U>::type>(0))==sizeof(::boost::type_traits::yes_type)> type; \ | |
75 | }; \ | |
76 | \ | |
77 | typedef typename ttc_md<BOOST_TTI_DETAIL_TP_T,BOOST_TTI_DETAIL_TP_C>::type type; \ | |
78 | \ | |
79 | }; \ | |
80 | /**/ | |
81 | ||
82 | #else // !defined(BOOST_MSVC) | |
83 | ||
84 | #include <boost/tti/detail/dmem_fun.hpp> | |
85 | ||
86 | #define BOOST_TTI_DETAIL_TRAIT_HAS_MEMBER_DATA_OP(trait,name) \ | |
87 | BOOST_TTI_DETAIL_TRAIT_HAS_TYPES_MEMBER_FUNCTION(trait,name) \ | |
88 | template<class BOOST_TTI_DETAIL_TP_T,class BOOST_TTI_DETAIL_TP_C> \ | |
89 | struct BOOST_PP_CAT(trait,_detail_hmd_op) : \ | |
90 | BOOST_PP_CAT(trait,_detail_types)<BOOST_TTI_DETAIL_TP_T,BOOST_TTI_DETAIL_TP_C> \ | |
91 | { \ | |
92 | }; \ | |
93 | /**/ | |
94 | ||
95 | #endif // defined(BOOST_MSVC) | |
96 | ||
97 | #define BOOST_TTI_DETAIL_TRAIT_HAS_MEMBER_DATA_INVOKE_ENCLOSING_CLASS(trait) \ | |
98 | template<class BOOST_TTI_DETAIL_TP_ET,class BOOST_TTI_DETAIL_TP_TYPE> \ | |
99 | struct BOOST_PP_CAT(trait,_detail_hmd_invoke_enclosing_class) : \ | |
100 | BOOST_PP_CAT(trait,_detail_hmd_op) \ | |
101 | < \ | |
102 | typename BOOST_TTI_NAMESPACE::detail::ptmd<BOOST_TTI_DETAIL_TP_ET,BOOST_TTI_DETAIL_TP_TYPE>::type, \ | |
103 | typename boost::remove_const<BOOST_TTI_DETAIL_TP_ET>::type \ | |
104 | > \ | |
105 | { \ | |
106 | }; \ | |
107 | /**/ | |
108 | ||
109 | #define BOOST_TTI_DETAIL_TRAIT_HAS_MEMBER_DATA_INVOKE_PT_MEMBER(trait) \ | |
110 | template<class BOOST_TTI_DETAIL_TP_ET,class BOOST_TTI_DETAIL_TP_TYPE> \ | |
111 | struct BOOST_PP_CAT(trait,_detail_hmd_invoke_pt_member) : \ | |
112 | BOOST_PP_CAT(trait,_detail_hmd_op) \ | |
113 | < \ | |
114 | typename BOOST_TTI_NAMESPACE::detail::dmem_get_type<BOOST_TTI_DETAIL_TP_ET,BOOST_TTI_DETAIL_TP_TYPE>::type, \ | |
115 | typename boost::remove_const \ | |
116 | < \ | |
117 | typename BOOST_TTI_NAMESPACE::detail::dmem_get_enclosing<BOOST_TTI_DETAIL_TP_ET,BOOST_TTI_DETAIL_TP_TYPE>::type \ | |
118 | >::type \ | |
119 | > \ | |
120 | { \ | |
121 | }; \ | |
122 | /**/ | |
123 | ||
124 | #define BOOST_TTI_DETAIL_TRAIT_HAS_MEMBER_DATA_WITH_ENCLOSING_CLASS(trait) \ | |
125 | BOOST_TTI_DETAIL_TRAIT_HAS_MEMBER_DATA_INVOKE_ENCLOSING_CLASS(trait) \ | |
126 | template<class BOOST_TTI_DETAIL_TP_ET,class BOOST_TTI_DETAIL_TP_TYPE> \ | |
127 | struct BOOST_PP_CAT(trait,_detail_hmd_with_enclosing_class) : \ | |
128 | boost::mpl::eval_if \ | |
129 | < \ | |
130 | boost::is_class<BOOST_TTI_DETAIL_TP_ET>, \ | |
131 | BOOST_PP_CAT(trait,_detail_hmd_invoke_enclosing_class) \ | |
132 | < \ | |
133 | BOOST_TTI_DETAIL_TP_ET, \ | |
134 | BOOST_TTI_DETAIL_TP_TYPE \ | |
135 | >, \ | |
136 | boost::mpl::false_ \ | |
137 | > \ | |
138 | { \ | |
139 | }; \ | |
140 | /**/ | |
141 | ||
142 | #define BOOST_TTI_DETAIL_TRAIT_HAS_MEMBER_DATA(trait,name) \ | |
143 | BOOST_TTI_DETAIL_TRAIT_HAS_MEMBER_DATA_OP(trait,name) \ | |
144 | BOOST_TTI_DETAIL_TRAIT_HAS_MEMBER_DATA_WITH_ENCLOSING_CLASS(trait) \ | |
145 | BOOST_TTI_DETAIL_TRAIT_HAS_MEMBER_DATA_INVOKE_PT_MEMBER(trait) \ | |
146 | template<class BOOST_TTI_DETAIL_TP_ET,class BOOST_TTI_DETAIL_TP_TYPE> \ | |
147 | struct BOOST_PP_CAT(trait,_detail_hmd) : \ | |
148 | boost::mpl::eval_if \ | |
149 | < \ | |
150 | boost::is_same<BOOST_TTI_DETAIL_TP_TYPE,BOOST_TTI_NAMESPACE::detail::deftype>, \ | |
151 | BOOST_PP_CAT(trait,_detail_hmd_invoke_pt_member) \ | |
152 | < \ | |
153 | BOOST_TTI_DETAIL_TP_ET, \ | |
154 | BOOST_TTI_DETAIL_TP_TYPE \ | |
155 | >, \ | |
156 | BOOST_PP_CAT(trait,_detail_hmd_with_enclosing_class) \ | |
157 | < \ | |
158 | BOOST_TTI_DETAIL_TP_ET, \ | |
159 | BOOST_TTI_DETAIL_TP_TYPE \ | |
160 | > \ | |
161 | > \ | |
162 | { \ | |
163 | }; \ | |
164 | /**/ | |
165 | ||
166 | namespace boost | |
167 | { | |
168 | namespace tti | |
169 | { | |
170 | namespace detail | |
171 | { | |
172 | ||
173 | template<class BOOST_TTI_DETAIL_TP_T,class BOOST_TTI_DETAIL_TP_R> | |
174 | struct ptmd | |
175 | { | |
176 | typedef BOOST_TTI_DETAIL_TP_R BOOST_TTI_DETAIL_TP_T::* type; | |
177 | }; | |
178 | ||
179 | template<class BOOST_TTI_DETAIL_TP_T> | |
180 | struct dmem_check_ptmd : | |
181 | boost::mpl::identity<BOOST_TTI_DETAIL_TP_T> | |
182 | { | |
183 | BOOST_MPL_ASSERT((boost::function_types::is_member_object_pointer<BOOST_TTI_DETAIL_TP_T>)); | |
184 | }; | |
185 | ||
186 | template<class BOOST_TTI_DETAIL_TP_T> | |
187 | struct dmem_check_ptec : | |
188 | BOOST_TTI_NAMESPACE::detail::class_type<BOOST_TTI_DETAIL_TP_T> | |
189 | { | |
190 | BOOST_MPL_ASSERT((boost::function_types::is_member_object_pointer<BOOST_TTI_DETAIL_TP_T>)); | |
191 | }; | |
192 | ||
193 | template<class BOOST_TTI_DETAIL_TP_T,class BOOST_TTI_DETAIL_TP_T2> | |
194 | struct dmem_get_type : | |
195 | boost::mpl::eval_if | |
196 | < | |
197 | boost::is_same<BOOST_TTI_DETAIL_TP_T2,BOOST_TTI_NAMESPACE::detail::deftype>, | |
198 | BOOST_TTI_NAMESPACE::detail::dmem_check_ptmd<BOOST_TTI_DETAIL_TP_T>, | |
199 | BOOST_TTI_NAMESPACE::detail::ptmd<BOOST_TTI_DETAIL_TP_T,BOOST_TTI_DETAIL_TP_T2> | |
200 | > | |
201 | { | |
202 | }; | |
203 | ||
204 | template<class BOOST_TTI_DETAIL_TP_T,class BOOST_TTI_DETAIL_TP_T2> | |
205 | struct dmem_get_enclosing : | |
206 | boost::mpl::eval_if | |
207 | < | |
208 | boost::is_same<BOOST_TTI_DETAIL_TP_T2,BOOST_TTI_NAMESPACE::detail::deftype>, | |
209 | BOOST_TTI_NAMESPACE::detail::dmem_check_ptec<BOOST_TTI_DETAIL_TP_T>, | |
210 | boost::mpl::identity<BOOST_TTI_DETAIL_TP_T> | |
211 | > | |
212 | { | |
213 | }; | |
214 | ||
215 | } | |
216 | } | |
217 | } | |
218 | ||
219 | #endif // BOOST_TTI_DETAIL_MEM_DATA_HPP |