]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/fusion/include/boost/fusion/adapted/struct/detail/adapt_base.hpp
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / boost / libs / fusion / include / boost / fusion / adapted / struct / detail / adapt_base.hpp
1 /*=============================================================================
2 Copyright (c) 2001-2009 Joel de Guzman
3 Copyright (c) 2005-2006 Dan Marsden
4 Copyright (c) 2009-2011 Christopher Schmidt
5 Copyright (c) 2013-2014 Damien Buhl
6
7 Distributed under the Boost Software License, Version 1.0. (See accompanying
8 file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
9 ==============================================================================*/
10
11 #ifndef BOOST_FUSION_ADAPTED_STRUCT_DETAIL_ADAPT_BASE_HPP
12 #define BOOST_FUSION_ADAPTED_STRUCT_DETAIL_ADAPT_BASE_HPP
13
14 #include <boost/fusion/support/config.hpp>
15 #include <boost/config.hpp>
16 #include <boost/fusion/support/tag_of_fwd.hpp>
17 #include <boost/fusion/adapted/struct/detail/adapt_auto.hpp>
18 #include <boost/fusion/adapted/struct/detail/adapt_is_tpl.hpp>
19
20 #include <boost/preprocessor/empty.hpp>
21 #include <boost/preprocessor/stringize.hpp>
22 #include <boost/preprocessor/control/if.hpp>
23 #include <boost/preprocessor/seq/size.hpp>
24 #include <boost/preprocessor/seq/for_each.hpp>
25 #include <boost/preprocessor/seq/for_each_i.hpp>
26 #include <boost/preprocessor/seq/enum.hpp>
27 #include <boost/preprocessor/seq/seq.hpp>
28 #include <boost/preprocessor/tuple/eat.hpp>
29 #include <boost/preprocessor/tuple/elem.hpp>
30 #include <boost/preprocessor/arithmetic/dec.hpp>
31 #include <boost/preprocessor/comparison/less.hpp>
32 #include <boost/preprocessor/logical/not.hpp>
33 #include <boost/mpl/bool.hpp>
34 #include <boost/mpl/tag.hpp>
35 #include <boost/mpl/eval_if.hpp>
36 #include <boost/mpl/identity.hpp>
37 #include <boost/type_traits/add_const.hpp>
38
39 #include <boost/typeof/typeof.hpp>
40
41
42 #define BOOST_FUSION_ADAPT_STRUCT_UNPACK_NAME_TEMPLATE_PARAMS(SEQ) \
43 BOOST_PP_SEQ_HEAD(SEQ)<BOOST_PP_SEQ_ENUM(BOOST_PP_SEQ_TAIL(SEQ))> \
44 BOOST_PP_EMPTY()
45
46 #define BOOST_FUSION_ADAPT_STRUCT_UNPACK_NAME(SEQ) \
47 BOOST_PP_IF( \
48 BOOST_PP_SEQ_HEAD(SEQ), \
49 BOOST_FUSION_ADAPT_STRUCT_UNPACK_NAME_TEMPLATE_PARAMS, \
50 BOOST_PP_SEQ_HEAD)(BOOST_PP_SEQ_TAIL(SEQ))
51
52 #define BOOST_FUSION_ADAPT_STRUCT_UNPACK_TEMPLATE_PARAMS_IMPL_C(R, _, ELEM) \
53 (typename ELEM)
54 #define BOOST_FUSION_ADAPT_STRUCT_UNPACK_TEMPLATE_PARAMS_IMPL(SEQ) \
55 BOOST_PP_SEQ_ENUM( \
56 BOOST_PP_SEQ_FOR_EACH( \
57 BOOST_FUSION_ADAPT_STRUCT_UNPACK_TEMPLATE_PARAMS_IMPL_C, \
58 _, \
59 BOOST_PP_SEQ_TAIL(SEQ)))
60 #define BOOST_FUSION_ADAPT_STRUCT_UNPACK_TEMPLATE_PARAMS(SEQ) \
61 BOOST_PP_IF( \
62 BOOST_PP_SEQ_HEAD(SEQ), \
63 BOOST_FUSION_ADAPT_STRUCT_UNPACK_TEMPLATE_PARAMS_IMPL, \
64 BOOST_PP_TUPLE_EAT(1))(SEQ)
65
66 #ifdef BOOST_MSVC
67 # define BOOST_FUSION_ATTRIBUTE_TYPEOF( \
68 NAME_SEQ, ATTRIBUTE, ATTRIBUTE_TUPLE_SIZE, PREFIX, TEMPLATE_PARAMS_SEQ) \
69 \
70 BOOST_FUSION_ADAPT_STRUCT_MSVC_REDEFINE_TEMPLATE_PARAMS( \
71 TEMPLATE_PARAMS_SEQ) \
72 \
73 struct deduced_attr_type { \
74 static const BOOST_FUSION_ADAPT_STRUCT_UNPACK_NAME(NAME_SEQ)& obj; \
75 typedef \
76 BOOST_PP_IF(BOOST_FUSION_ADAPT_IS_TPL(TEMPLATE_PARAMS_SEQ), typename, ) \
77 BOOST_TYPEOF( PREFIX() obj.BOOST_PP_TUPLE_ELEM(ATTRIBUTE_TUPLE_SIZE, \
78 0, ATTRIBUTE)) \
79 type; \
80 }; \
81 \
82 typedef \
83 BOOST_PP_IF(BOOST_FUSION_ADAPT_IS_TPL(TEMPLATE_PARAMS_SEQ), typename, ) \
84 deduced_attr_type::type attribute_type;
85
86 #else
87 # define BOOST_FUSION_ATTRIBUTE_TYPEOF( \
88 NAME_SEQ, ATTRIBUTE, ATTRIBUTE_TUPLE_SIZE, PREFIX, TEMPLATE_PARAMS_SEQ) \
89 \
90 struct deduced_attr_type { \
91 static const BOOST_FUSION_ADAPT_STRUCT_UNPACK_NAME(NAME_SEQ)& obj; \
92 typedef BOOST_TYPEOF( \
93 PREFIX() obj.BOOST_PP_TUPLE_ELEM(ATTRIBUTE_TUPLE_SIZE, 0, ATTRIBUTE)) \
94 type; \
95 }; \
96 \
97 typedef \
98 BOOST_PP_IF(BOOST_FUSION_ADAPT_IS_TPL(TEMPLATE_PARAMS_SEQ), typename, ) \
99 deduced_attr_type::type attribute_type;
100
101 #endif
102
103 #define BOOST_FUSION_ATTRIBUTE_GIVENTYPE( \
104 NAME_SEQ, ATTRIBUTE, ATTRIBUTE_TUPLE_SIZE, PREFIX, TEMPLATE_PARAMS_SEQ) \
105 typedef \
106 BOOST_PP_TUPLE_ELEM(ATTRIBUTE_TUPLE_SIZE, 0, ATTRIBUTE) attribute_type;
107
108
109 #ifdef BOOST_NO_PARTIAL_SPECIALIZATION_IMPLICIT_DEFAULT_ARGS
110 # define BOOST_FUSION_ADAPT_STRUCT_TAG_OF_SPECIALIZATION( \
111 MODIFIER, TEMPLATE_PARAMS_SEQ, NAME_SEQ, TAG) \
112 \
113 template< \
114 BOOST_FUSION_ADAPT_STRUCT_UNPACK_TEMPLATE_PARAMS(TEMPLATE_PARAMS_SEQ) \
115 > \
116 struct tag_of< \
117 BOOST_FUSION_ADAPT_STRUCT_UNPACK_NAME(NAME_SEQ) MODIFIER \
118 , void \
119 > \
120 { \
121 typedef TAG type; \
122 };
123 #else
124 # define BOOST_FUSION_ADAPT_STRUCT_TAG_OF_SPECIALIZATION( \
125 MODIFIER, TEMPLATE_PARAMS_SEQ, NAME_SEQ, TAG) \
126 \
127 template< \
128 BOOST_FUSION_ADAPT_STRUCT_UNPACK_TEMPLATE_PARAMS(TEMPLATE_PARAMS_SEQ) \
129 > \
130 struct tag_of<BOOST_FUSION_ADAPT_STRUCT_UNPACK_NAME(NAME_SEQ) MODIFIER> \
131 { \
132 typedef TAG type; \
133 };
134 #endif
135
136 #define BOOST_FUSION_ADAPT_STRUCT_BASE_UNPACK_AND_CALL(R,DATA,I,ATTRIBUTE) \
137 BOOST_PP_TUPLE_ELEM(4,0,DATA)( \
138 BOOST_PP_TUPLE_ELEM(4,1,DATA), \
139 BOOST_PP_TUPLE_ELEM(4,2,DATA), \
140 BOOST_PP_TUPLE_ELEM(4,3,DATA), \
141 I, \
142 ATTRIBUTE)
143
144 #ifdef BOOST_MSVC
145 # define BOOST_FUSION_ADAPT_STRUCT_MSVC_REDEFINE_TEMPLATE_PARAM(R,_,ELEM) \
146 typedef ELEM ELEM;
147 # define BOOST_FUSION_ADAPT_STRUCT_MSVC_REDEFINE_TEMPLATE_PARAMS_IMPL(SEQ) \
148 BOOST_PP_SEQ_FOR_EACH( \
149 BOOST_FUSION_ADAPT_STRUCT_MSVC_REDEFINE_TEMPLATE_PARAM, \
150 _, \
151 BOOST_PP_SEQ_TAIL(SEQ))
152 # define BOOST_FUSION_ADAPT_STRUCT_MSVC_REDEFINE_TEMPLATE_PARAMS(SEQ) \
153 BOOST_PP_IF( \
154 BOOST_PP_SEQ_HEAD(SEQ), \
155 BOOST_FUSION_ADAPT_STRUCT_MSVC_REDEFINE_TEMPLATE_PARAMS_IMPL, \
156 BOOST_PP_TUPLE_EAT(1))(SEQ)
157 #else
158 # define BOOST_FUSION_ADAPT_STRUCT_MSVC_REDEFINE_TEMPLATE_PARAMS(SEQ)
159 #endif
160
161 #define BOOST_FUSION_ADAPT_STRUCT_C_BASE( \
162 TEMPLATE_PARAMS_SEQ,NAME_SEQ,IS_VIEW, \
163 I,PREFIX,ATTRIBUTE,ATTRIBUTE_TUPLE_SIZE, \
164 DEDUCE_TYPE) \
165 \
166 template< \
167 BOOST_FUSION_ADAPT_STRUCT_UNPACK_TEMPLATE_PARAMS(TEMPLATE_PARAMS_SEQ) \
168 > \
169 struct access::struct_member< \
170 BOOST_FUSION_ADAPT_STRUCT_UNPACK_NAME(NAME_SEQ) \
171 , I \
172 > \
173 { \
174 BOOST_PP_IF(DEDUCE_TYPE, \
175 BOOST_FUSION_ATTRIBUTE_TYPEOF, BOOST_FUSION_ATTRIBUTE_GIVENTYPE)( \
176 NAME_SEQ, \
177 ATTRIBUTE, \
178 ATTRIBUTE_TUPLE_SIZE, \
179 PREFIX, \
180 TEMPLATE_PARAMS_SEQ) \
181 \
182 BOOST_FUSION_ADAPT_STRUCT_MSVC_REDEFINE_TEMPLATE_PARAMS( \
183 TEMPLATE_PARAMS_SEQ) \
184 \
185 typedef attribute_type type; \
186 \
187 template<typename Seq> \
188 struct apply \
189 { \
190 typedef typename \
191 add_reference< \
192 typename mpl::eval_if< \
193 is_const<Seq> \
194 , add_const<attribute_type> \
195 , mpl::identity<attribute_type> \
196 >::type \
197 >::type \
198 type; \
199 \
200 BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED \
201 static type \
202 call(Seq& seq) \
203 { \
204 return seq.PREFIX() \
205 BOOST_PP_TUPLE_ELEM(ATTRIBUTE_TUPLE_SIZE, \
206 BOOST_PP_NOT(DEDUCE_TYPE), ATTRIBUTE); \
207 } \
208 }; \
209 }; \
210 \
211 template< \
212 BOOST_FUSION_ADAPT_STRUCT_UNPACK_TEMPLATE_PARAMS(TEMPLATE_PARAMS_SEQ) \
213 > \
214 struct struct_member_name< \
215 BOOST_FUSION_ADAPT_STRUCT_UNPACK_NAME(NAME_SEQ) \
216 , I \
217 > \
218 { \
219 typedef char const* type; \
220 \
221 BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED \
222 static type \
223 call() \
224 { \
225 return BOOST_PP_STRINGIZE( \
226 BOOST_PP_TUPLE_ELEM(ATTRIBUTE_TUPLE_SIZE, \
227 BOOST_PP_NOT(DEDUCE_TYPE), ATTRIBUTE)); \
228 } \
229 };
230
231 #define BOOST_FUSION_ADAPT_STRUCT_BASE( \
232 TEMPLATE_PARAMS_SEQ, \
233 NAME_SEQ, \
234 TAG, \
235 IS_VIEW, \
236 ATTRIBUTES_SEQ, \
237 ATTRIBUTES_CALLBACK) \
238 \
239 namespace boost \
240 { \
241 namespace fusion \
242 { \
243 namespace traits \
244 { \
245 BOOST_FUSION_ADAPT_STRUCT_TAG_OF_SPECIALIZATION( \
246 BOOST_PP_EMPTY(), TEMPLATE_PARAMS_SEQ, NAME_SEQ, TAG) \
247 BOOST_FUSION_ADAPT_STRUCT_TAG_OF_SPECIALIZATION( \
248 const, TEMPLATE_PARAMS_SEQ, NAME_SEQ, TAG) \
249 } \
250 \
251 namespace extension \
252 { \
253 BOOST_PP_IF( \
254 BOOST_PP_DEC(BOOST_PP_SEQ_SIZE(ATTRIBUTES_SEQ)), \
255 BOOST_PP_SEQ_FOR_EACH_I_R, \
256 BOOST_PP_TUPLE_EAT(4))( \
257 1, \
258 BOOST_FUSION_ADAPT_STRUCT_BASE_UNPACK_AND_CALL, \
259 (ATTRIBUTES_CALLBACK,TEMPLATE_PARAMS_SEQ,NAME_SEQ, IS_VIEW),\
260 BOOST_PP_SEQ_TAIL(ATTRIBUTES_SEQ)) \
261 \
262 template< \
263 BOOST_FUSION_ADAPT_STRUCT_UNPACK_TEMPLATE_PARAMS( \
264 TEMPLATE_PARAMS_SEQ) \
265 > \
266 struct struct_size<BOOST_FUSION_ADAPT_STRUCT_UNPACK_NAME(NAME_SEQ)> \
267 : mpl::int_<BOOST_PP_DEC(BOOST_PP_SEQ_SIZE(ATTRIBUTES_SEQ))> \
268 {}; \
269 \
270 template< \
271 BOOST_FUSION_ADAPT_STRUCT_UNPACK_TEMPLATE_PARAMS( \
272 TEMPLATE_PARAMS_SEQ) \
273 > \
274 struct struct_is_view< \
275 BOOST_FUSION_ADAPT_STRUCT_UNPACK_NAME(NAME_SEQ) \
276 > \
277 : mpl::BOOST_PP_IIF(IS_VIEW,true_,false_) \
278 {}; \
279 } \
280 } \
281 \
282 namespace mpl \
283 { \
284 template<typename> \
285 struct sequence_tag; \
286 \
287 template< \
288 BOOST_FUSION_ADAPT_STRUCT_UNPACK_TEMPLATE_PARAMS( \
289 TEMPLATE_PARAMS_SEQ) \
290 > \
291 struct sequence_tag<BOOST_FUSION_ADAPT_STRUCT_UNPACK_NAME(NAME_SEQ)> \
292 { \
293 typedef fusion::fusion_sequence_tag type; \
294 }; \
295 \
296 template< \
297 BOOST_FUSION_ADAPT_STRUCT_UNPACK_TEMPLATE_PARAMS( \
298 TEMPLATE_PARAMS_SEQ) \
299 > \
300 struct sequence_tag< \
301 BOOST_FUSION_ADAPT_STRUCT_UNPACK_NAME(NAME_SEQ) const \
302 > \
303 { \
304 typedef fusion::fusion_sequence_tag type; \
305 }; \
306 } \
307 }
308
309 #endif