• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*=============================================================================
2     Copyright (c) 2010-2011 Christopher Schmidt
3 
4     Distributed under the Boost Software License, Version 1.0. (See accompanying
5     file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
6 ==============================================================================*/
7 
8 #ifndef BOOST_FUSION_ADAPTED_DETAIL_STRUCT_DEFINE_STRUCT_HPP
9 #define BOOST_FUSION_ADAPTED_DETAIL_STRUCT_DEFINE_STRUCT_HPP
10 
11 #include <boost/fusion/support/config.hpp>
12 #include <boost/config.hpp>
13 #include <boost/detail/workaround.hpp>
14 #include <boost/fusion/sequence/intrinsic/begin.hpp>
15 #include <boost/fusion/iterator/deref.hpp>
16 #include <boost/fusion/iterator/next.hpp>
17 #include <boost/fusion/iterator/advance.hpp>
18 #include <boost/fusion/adapted/struct/detail/adapt_base.hpp>
19 #include <boost/fusion/adapted/struct/detail/namespace.hpp>
20 #include <boost/preprocessor/if.hpp>
21 #include <boost/preprocessor/expr_if.hpp>
22 #include <boost/preprocessor/dec.hpp>
23 #include <boost/preprocessor/logical/not.hpp>
24 #include <boost/preprocessor/punctuation/comma_if.hpp>
25 #include <boost/preprocessor/seq/seq.hpp>
26 #include <boost/preprocessor/seq/for_each.hpp>
27 #include <boost/preprocessor/seq/for_each_i.hpp>
28 #include <boost/preprocessor/seq/enum.hpp>
29 #include <boost/preprocessor/seq/size.hpp>
30 #include <boost/preprocessor/tuple/elem.hpp>
31 #include <boost/preprocessor/tuple/eat.hpp>
32 #include <boost/call_traits.hpp>
33 #include <boost/type_traits/is_convertible.hpp>
34 #include <boost/utility/enable_if.hpp>
35 
36 #define BOOST_FUSION_DEFINE_STRUCT_FILLER_0(X, Y)                               \
37     ((X, Y)) BOOST_FUSION_DEFINE_STRUCT_FILLER_1
38 #define BOOST_FUSION_DEFINE_STRUCT_FILLER_1(X, Y)                               \
39     ((X, Y)) BOOST_FUSION_DEFINE_STRUCT_FILLER_0
40 #define BOOST_FUSION_DEFINE_STRUCT_FILLER_0_END
41 #define BOOST_FUSION_DEFINE_STRUCT_FILLER_1_END
42 
43 #ifdef BOOST_NO_CXX11_DEFAULTED_FUNCTIONS
44 
45 #define BOOST_FUSION_DEFINE_STRUCT_COPY_CTOR_FILLER_I(                          \
46     R, ATTRIBUTE_TUPLE_SIZE, I, ATTRIBUTE)                                      \
47                                                                                 \
48     BOOST_PP_COMMA_IF(I)                                                        \
49     BOOST_PP_TUPLE_ELEM(ATTRIBUTE_TUPLE_SIZE,1,ATTRIBUTE)(                      \
50         other_self.BOOST_PP_TUPLE_ELEM(ATTRIBUTE_TUPLE_SIZE,1,ATTRIBUTE))
51 
52 #define BOOST_FUSION_DEFINE_STRUCT_COPY_CTOR(                                   \
53     NAME, ATTRIBUTES_SEQ, ATTRIBUTE_TUPLE_SIZE)                                 \
54                                                                                 \
55     BOOST_FUSION_GPU_ENABLED                                                    \
56     NAME(self_type const& other_self)                                           \
57       : BOOST_PP_SEQ_FOR_EACH_I_R(                                              \
58             1,                                                                  \
59             BOOST_FUSION_DEFINE_STRUCT_COPY_CTOR_FILLER_I,                      \
60             ATTRIBUTE_TUPLE_SIZE,                                               \
61             ATTRIBUTES_SEQ)                                                     \
62     {}
63 
64 // Use templated version instead.
65 #define BOOST_FUSION_DEFINE_STRUCT_COPY_ASSIGN_FILLER_I(                        \
66     R, ATTRIBUTE_TUPLE_SIZE, I_, ATTRIBUTE)                                     \
67                                                                                 \
68     BOOST_PP_TUPLE_ELEM(ATTRIBUTE_TUPLE_SIZE,1,ATTRIBUTE)=                      \
69         other.BOOST_PP_TUPLE_ELEM(ATTRIBUTE_TUPLE_SIZE,1,ATTRIBUTE);
70 
71 #define BOOST_FUSION_DEFINE_STRUCT_COPY_ASSIGN_OP(                              \
72     ATTRIBUTES_SEQ, ATTRIBUTE_TUPLE_SIZE)                                       \
73                                                                                 \
74     BOOST_FUSION_GPU_ENABLED                                                    \
75     self_type& operator=(self_type const& other)                                \
76     {                                                                           \
77         BOOST_PP_SEQ_FOR_EACH_I_R(                                              \
78             1,                                                                  \
79             BOOST_FUSION_DEFINE_STRUCT_COPY_ASSIGN_FILLER_I,                    \
80             ATTRIBUTE_TUPLE_SIZE,                                               \
81             ATTRIBUTES_SEQ)                                                     \
82                                                                                 \
83         return *this;                                                           \
84     }
85 
86 #else // BOOST_NO_CXX11_DEFAULTED_FUNCTIONS
87 
88 #define BOOST_FUSION_DEFINE_STRUCT_COPY_CTOR(                                   \
89     NAME, ATTRIBUTES_SEQ, ATTRIBUTE_TUPLE_SIZE)                                 \
90                                                                                 \
91     BOOST_FUSION_GPU_ENABLED NAME(self_type const&) = default;
92 
93 #define BOOST_FUSION_DEFINE_STRUCT_COPY_ASSIGN_OP(                              \
94     ATTRIBUTES_SEQ, ATTRIBUTE_TUPLE_SIZE)                                       \
95                                                                                 \
96     BOOST_FUSION_GPU_ENABLED self_type& operator=(self_type const&) = default;
97 
98 #endif // BOOST_NO_CXX11_DEFAULTED_FUNCTIONS
99 
100 #define BOOST_FUSION_DEFINE_STRUCT_ASSIGN_FILLER_I(                             \
101     R, ATTRIBUTE_TUPLE_SIZE, I_, ATTRIBUTE)                                     \
102                                                                                 \
103     BOOST_PP_EXPR_IF(                                                           \
104         I_,                                                                     \
105         typedef typename                                                        \
106             boost::fusion::result_of::next<                                     \
107                 BOOST_PP_CAT(I,BOOST_PP_DEC(I_))                                \
108             >::type                                                             \
109         BOOST_PP_CAT(I,I_);                                                     \
110         BOOST_PP_CAT(I,I_) BOOST_PP_CAT(i,I_)=                                  \
111                 boost::fusion::next(BOOST_PP_CAT(i,BOOST_PP_DEC(I_)));          \
112     )                                                                           \
113                                                                                 \
114     BOOST_PP_TUPLE_ELEM(ATTRIBUTE_TUPLE_SIZE,1,ATTRIBUTE)=                      \
115         boost::fusion::deref(BOOST_PP_CAT(i,I_));
116 
117 #define BOOST_FUSION_DEFINE_STRUCT_ASSIGN_OP(                                   \
118     ATTRIBUTES_SEQ, ATTRIBUTE_TUPLE_SIZE)                                       \
119                                                                                 \
120     template<typename Seq>                                                      \
121     BOOST_FUSION_GPU_ENABLED                                                    \
122     self_type&                                                                  \
123     operator=(Seq const& seq)                                                   \
124     {                                                                           \
125         typedef typename                                                        \
126             boost::fusion::result_of::begin<Seq const>::type                    \
127         I0;                                                                     \
128         I0 i0=boost::fusion::begin(seq);                                        \
129                                                                                 \
130         BOOST_PP_SEQ_FOR_EACH_I_R(                                              \
131             1,                                                                  \
132             BOOST_FUSION_DEFINE_STRUCT_ASSIGN_FILLER_I,                         \
133             ATTRIBUTE_TUPLE_SIZE,                                               \
134             ATTRIBUTES_SEQ)                                                     \
135                                                                                 \
136         return *this;                                                           \
137     }
138 
139 #ifdef BOOST_NO_CXX11_RVALUE_REFERENCES
140 
141 #define BOOST_FUSION_DEFINE_STRUCT_MOVE_CTOR(NAME, ATTRIBUTES_SEQ, ATTRIBUTE_TUPLE_SIZE)
142 #define BOOST_FUSION_DEFINE_STRUCT_MOVE_ASSIGN_OP(ATTRIBUTES_SEQ, ATTRIBUTE_TUPLE_SIZE)
143 
144 #else // BOOST_NO_CXX11_RVALUE_REFERENCES
145 
146 #if defined(BOOST_NO_CXX11_DEFAULTED_FUNCTIONS) \
147  || BOOST_WORKAROUND(BOOST_GCC, < 40500) \
148  || BOOST_WORKAROUND(BOOST_MSVC, == 1800)
149 
150 #define BOOST_FUSION_DEFINE_STRUCT_MOVE_CTOR_FILLER_I(                          \
151     R, ATTRIBUTE_TUPLE_SIZE, I, ATTRIBUTE)                                      \
152                                                                                 \
153     BOOST_PP_COMMA_IF(I)                                                        \
154     BOOST_PP_TUPLE_ELEM(ATTRIBUTE_TUPLE_SIZE,1,ATTRIBUTE)(std::move(            \
155         other_self.BOOST_PP_TUPLE_ELEM(ATTRIBUTE_TUPLE_SIZE,1,ATTRIBUTE)))
156 
157 #define BOOST_FUSION_DEFINE_STRUCT_MOVE_CTOR(                                   \
158     NAME, ATTRIBUTES_SEQ, ATTRIBUTE_TUPLE_SIZE)                                 \
159                                                                                 \
160     BOOST_FUSION_GPU_ENABLED                                                    \
161     NAME(self_type&& other_self)                                                \
162       : BOOST_PP_SEQ_FOR_EACH_I_R(                                              \
163             1,                                                                  \
164             BOOST_FUSION_DEFINE_STRUCT_MOVE_CTOR_FILLER_I,                      \
165             ATTRIBUTE_TUPLE_SIZE,                                               \
166             ATTRIBUTES_SEQ)                                                     \
167     {}
168 
169 #else // BOOST_NO_CXX11_DEFAULTED_FUNCTIONS
170 
171 #define BOOST_FUSION_DEFINE_STRUCT_MOVE_CTOR(                                   \
172     NAME, ATTRIBUTES_SEQ, ATTRIBUTE_TUPLE_SIZE)                                 \
173                                                                                 \
174     BOOST_FUSION_GPU_ENABLED NAME(self_type&&) = default;
175 
176 #endif // BOOST_NO_CXX11_DEFAULTED_FUNCTIONS
177 
178 #if defined(BOOST_NO_CXX11_DEFAULTED_FUNCTIONS) \
179  || BOOST_WORKAROUND(BOOST_GCC, < 40600) \
180  || BOOST_WORKAROUND(BOOST_MSVC, == 1800)
181 
182 #define BOOST_FUSION_DEFINE_STRUCT_MOVE_ASSIGN_FILLER_I(                        \
183     R, ATTRIBUTE_TUPLE_SIZE, I_, ATTRIBUTE)                                     \
184                                                                                 \
185     BOOST_PP_TUPLE_ELEM(ATTRIBUTE_TUPLE_SIZE,1,ATTRIBUTE)=std::move(            \
186         other.BOOST_PP_TUPLE_ELEM(ATTRIBUTE_TUPLE_SIZE,1,ATTRIBUTE));
187 
188 #define BOOST_FUSION_DEFINE_STRUCT_MOVE_ASSIGN_OP(                              \
189     ATTRIBUTES_SEQ, ATTRIBUTE_TUPLE_SIZE)                                       \
190                                                                                 \
191     BOOST_FUSION_GPU_ENABLED                                                    \
192     self_type& operator=(self_type&& other)                                     \
193     {                                                                           \
194         BOOST_PP_SEQ_FOR_EACH_I_R(                                              \
195             1,                                                                  \
196             BOOST_FUSION_DEFINE_STRUCT_MOVE_ASSIGN_FILLER_I,                    \
197             ATTRIBUTE_TUPLE_SIZE,                                               \
198             ATTRIBUTES_SEQ)                                                     \
199                                                                                 \
200         return *this;                                                           \
201     }
202 
203 #else // BOOST_NO_CXX11_DEFAULTED_FUNCTIONS
204 
205 #define BOOST_FUSION_DEFINE_STRUCT_MOVE_ASSIGN_OP(                              \
206     ATTRIBUTES_SEQ, ATTRIBUTE_TUPLE_SIZE)                                       \
207                                                                                 \
208     BOOST_FUSION_GPU_ENABLED self_type& operator=(self_type&&) = default;
209 
210 #endif // BOOST_NO_CXX11_DEFAULTED_FUNCTIONS
211 
212 #endif // BOOST_NO_CXX11_RVALUE_REFERENCES
213 
214 #define BOOST_FUSION_DEFINE_STRUCT_ATTR_I(R, ATTRIBUTE_TUPLE_SIZE, ATTRIBUTE)   \
215                                                                                 \
216     BOOST_PP_TUPLE_ELEM(ATTRIBUTE_TUPLE_SIZE,0,ATTRIBUTE)                       \
217         BOOST_PP_TUPLE_ELEM(ATTRIBUTE_TUPLE_SIZE,1,ATTRIBUTE);
218 
219 #define BOOST_FUSION_DEFINE_STRUCT_SEQ_CTOR_FILLER_I(                           \
220     R, ATTRIBUTE_TUPLE_SIZE, I, ATTRIBUTE)                                      \
221                                                                                 \
222     BOOST_PP_COMMA_IF(I)                                                        \
223     BOOST_PP_TUPLE_ELEM(ATTRIBUTE_TUPLE_SIZE,1,ATTRIBUTE)(                      \
224         boost::fusion::deref(boost::fusion::advance_c<I>(boost::fusion::begin(  \
225             seq))))
226 
227 #define BOOST_FUSION_DEFINE_STRUCT_SEQ_CTOR_DISABLER(                           \
228     ATTRIBUTES_SEQ, ATTRIBUTE_TUPLE_SIZE)                                       \
229                                                                                 \
230     , typename boost::disable_if<                                               \
231         boost::is_convertible<                                                  \
232             Seq const&                                                          \
233           , BOOST_PP_TUPLE_ELEM(                                                \
234                 ATTRIBUTE_TUPLE_SIZE,                                           \
235                 0,                                                              \
236                 BOOST_PP_SEQ_HEAD(ATTRIBUTES_SEQ))                              \
237         >                                                                       \
238     >::type* =0
239 
240 #define BOOST_FUSION_DEFINE_STRUCT_SEQ_DEFAULT_CTOR_FILLER_I(                   \
241     R, ATTRIBUTE_TUPLE_SIZE, I, ATTRIBUTE)                                      \
242                                                                                 \
243     BOOST_PP_COMMA_IF(I)                                                        \
244     BOOST_PP_TUPLE_ELEM(ATTRIBUTE_TUPLE_SIZE,1,ATTRIBUTE)()
245 
246 #define BOOST_FUSION_DEFINE_STRUCT_IMPL_IMPL(                                   \
247     NAME, ATTRIBUTES_SEQ, ATTRIBUTE_TUPLE_SIZE)                                 \
248                                                                                 \
249     BOOST_PP_SEQ_FOR_EACH_R(                                                    \
250         1,                                                                      \
251         BOOST_FUSION_DEFINE_STRUCT_ATTR_I,                                      \
252         ATTRIBUTE_TUPLE_SIZE,                                                   \
253         ATTRIBUTES_SEQ)                                                         \
254                                                                                 \
255     BOOST_FUSION_GPU_ENABLED                                                    \
256     NAME()                                                                      \
257       : BOOST_PP_SEQ_FOR_EACH_I_R(                                              \
258             1,                                                                  \
259             BOOST_FUSION_DEFINE_STRUCT_SEQ_DEFAULT_CTOR_FILLER_I,               \
260             ATTRIBUTE_TUPLE_SIZE,                                               \
261             ATTRIBUTES_SEQ)                                                     \
262     {}                                                                          \
263                                                                                 \
264     BOOST_FUSION_DEFINE_STRUCT_COPY_CTOR(                                       \
265         NAME, ATTRIBUTES_SEQ, ATTRIBUTE_TUPLE_SIZE)  \
266     BOOST_FUSION_DEFINE_STRUCT_MOVE_CTOR(                                       \
267         NAME, ATTRIBUTES_SEQ, ATTRIBUTE_TUPLE_SIZE)  \
268                                                                                 \
269     template<typename Seq>                                                      \
270     BOOST_FUSION_GPU_ENABLED                                                    \
271     NAME(Seq const& seq                                                         \
272         BOOST_PP_IF(                                                            \
273             BOOST_PP_DEC(BOOST_PP_SEQ_SIZE(ATTRIBUTES_SEQ)),                    \
274             BOOST_PP_TUPLE_EAT(2),                                              \
275             BOOST_FUSION_DEFINE_STRUCT_SEQ_CTOR_DISABLER)(                      \
276                 ATTRIBUTES_SEQ, ATTRIBUTE_TUPLE_SIZE)                           \
277         )                                                                       \
278       : BOOST_PP_SEQ_FOR_EACH_I_R(                                              \
279             1,                                                                  \
280             BOOST_FUSION_DEFINE_STRUCT_SEQ_CTOR_FILLER_I,                       \
281             ATTRIBUTE_TUPLE_SIZE,                                               \
282             ATTRIBUTES_SEQ)                                                     \
283     {}                                                                          \
284                                                                                 \
285     BOOST_FUSION_DEFINE_STRUCT_COPY_ASSIGN_OP(                                  \
286         ATTRIBUTES_SEQ, ATTRIBUTE_TUPLE_SIZE)                                   \
287     BOOST_FUSION_DEFINE_STRUCT_MOVE_ASSIGN_OP(                                  \
288         ATTRIBUTES_SEQ, ATTRIBUTE_TUPLE_SIZE)                                   \
289     BOOST_FUSION_DEFINE_STRUCT_ASSIGN_OP(ATTRIBUTES_SEQ, ATTRIBUTE_TUPLE_SIZE)
290 
291 #define BOOST_FUSION_DEFINE_STRUCT_CTOR_1(                                      \
292         NAME, ATTRIBUTES_SEQ, ATTRIBUTE_TUPLE_SIZE)                             \
293                                                                                 \
294         BOOST_FUSION_GPU_ENABLED                                                \
295         explicit                                                                \
296         NAME(boost::call_traits<                                                \
297                 BOOST_PP_TUPLE_ELEM(                                            \
298                     ATTRIBUTE_TUPLE_SIZE,0,BOOST_PP_SEQ_HEAD(ATTRIBUTES_SEQ))   \
299             >::param_type arg)                                                  \
300           : BOOST_PP_TUPLE_ELEM(                                                \
301                 ATTRIBUTE_TUPLE_SIZE,1,BOOST_PP_SEQ_HEAD(ATTRIBUTES_SEQ))(arg)  \
302         {}
303 
304 #define BOOST_FUSION_DEFINE_TPL_STRUCT_CTOR_1(                                  \
305         TEMPLATE_PARAMS_SEQ, NAME, ATTRIBUTES_SEQ, ATTRIBUTE_TUPLE_SIZE)        \
306                                                                                 \
307         BOOST_FUSION_GPU_ENABLED                                                \
308         explicit                                                                \
309         NAME(typename boost::call_traits<                                       \
310                 typename boost::fusion::detail::get_first_arg<                  \
311                     BOOST_PP_TUPLE_ELEM(                                        \
312                         ATTRIBUTE_TUPLE_SIZE,                                   \
313                         0,                                                      \
314                         BOOST_PP_SEQ_HEAD(ATTRIBUTES_SEQ))                      \
315                   , BOOST_PP_SEQ_HEAD(TEMPLATE_PARAMS_SEQ)                      \
316                 >::type                                                         \
317             >::param_type arg)                                                  \
318           : BOOST_PP_TUPLE_ELEM(                                                \
319                 ATTRIBUTE_TUPLE_SIZE,1,BOOST_PP_SEQ_HEAD(ATTRIBUTES_SEQ))(arg)  \
320         {}
321 
322 #define BOOST_FUSION_DEFINE_STRUCT_CTOR_FILLER_I(                               \
323     R, ATTRIBUTE_TUPLE_SIZE, I, ATTRIBUTE)                                      \
324                                                                                 \
325     BOOST_PP_COMMA_IF(I)                                                        \
326     BOOST_PP_TUPLE_ELEM(ATTRIBUTE_TUPLE_SIZE,1,ATTRIBUTE)(BOOST_PP_CAT(_,I))
327 
328 #define BOOST_FUSION_DEFINE_TPL_STRUCT_CTOR_ARG_I(R, DATA, I, ATTRIBUTE)        \
329                                                                                 \
330         BOOST_PP_COMMA_IF(I)                                                    \
331         typename boost::call_traits<                                            \
332             typename boost::fusion::detail::get_first_arg<                      \
333                 BOOST_PP_TUPLE_ELEM(                                            \
334                     BOOST_PP_TUPLE_ELEM(3,0,DATA),                              \
335                     0,                                                          \
336                     ATTRIBUTE)                                                  \
337               , BOOST_PP_TUPLE_ELEM(3,2,DATA)                                   \
338             >::type                                                             \
339         >::param_type BOOST_PP_CAT(_,I)
340 
341 #define BOOST_FUSION_DEFINE_TPL_STRUCT_CTOR_N(                                  \
342     TEMPLATE_PARAMS_SEQ, NAME, ATTRIBUTES_SEQ, ATTRIBUTE_TUPLE_SIZE)            \
343                                                                                 \
344         BOOST_FUSION_GPU_ENABLED                                                \
345         NAME(BOOST_PP_SEQ_FOR_EACH_I_R(                                         \
346                 1,                                                              \
347                 BOOST_FUSION_DEFINE_TPL_STRUCT_CTOR_ARG_I,                      \
348                 (                                                               \
349                     ATTRIBUTE_TUPLE_SIZE,                                       \
350                     BOOST_PP_SEQ_SIZE(ATTRIBUTES_SEQ),                          \
351                     BOOST_PP_SEQ_HEAD(TEMPLATE_PARAMS_SEQ)                      \
352                 ),                                                              \
353                 ATTRIBUTES_SEQ))                                                \
354           : BOOST_PP_SEQ_FOR_EACH_I_R(                                          \
355                 1,                                                              \
356                 BOOST_FUSION_DEFINE_STRUCT_CTOR_FILLER_I,                       \
357                 ATTRIBUTE_TUPLE_SIZE,                                           \
358                 ATTRIBUTES_SEQ)                                                 \
359         {}
360 
361 #define BOOST_FUSION_DEFINE_STRUCT_CTOR_ARG_I(                                  \
362         R, ATTRIBUTE_TUPLE_SIZE, I, ATTRIBUTE)                                  \
363                                                                                 \
364         BOOST_PP_COMMA_IF(I)                                                    \
365         boost::call_traits<                                                     \
366             BOOST_PP_TUPLE_ELEM(ATTRIBUTE_TUPLE_SIZE,0,ATTRIBUTE)               \
367         >::param_type BOOST_PP_CAT(_,I)
368 
369 #define BOOST_FUSION_DEFINE_STRUCT_CTOR_N(                                      \
370     NAME, ATTRIBUTES_SEQ, ATTRIBUTE_TUPLE_SIZE)                                 \
371                                                                                 \
372         BOOST_FUSION_GPU_ENABLED                                \
373         NAME(BOOST_PP_SEQ_FOR_EACH_I_R(                                         \
374                 1,                                                              \
375                 BOOST_FUSION_DEFINE_STRUCT_CTOR_ARG_I,                          \
376                 ATTRIBUTE_TUPLE_SIZE,                                           \
377                 ATTRIBUTES_SEQ))                                                \
378           : BOOST_PP_SEQ_FOR_EACH_I_R(                                          \
379                 1,                                                              \
380                 BOOST_FUSION_DEFINE_STRUCT_CTOR_FILLER_I,                       \
381                 ATTRIBUTE_TUPLE_SIZE,                                           \
382                 ATTRIBUTES_SEQ)                                                 \
383         {}
384 
385 #define BOOST_FUSION_DEFINE_STRUCT_CTOR(                                        \
386     NAME, ATTRIBUTES_SEQ, ATTRIBUTE_TUPLE_SIZE)                                 \
387                                                                                 \
388     BOOST_PP_IF(BOOST_PP_DEC(BOOST_PP_SEQ_SIZE(ATTRIBUTES_SEQ)),                \
389         BOOST_FUSION_DEFINE_STRUCT_CTOR_N,                                      \
390         BOOST_FUSION_DEFINE_STRUCT_CTOR_1)(                                     \
391             NAME, ATTRIBUTES_SEQ, ATTRIBUTE_TUPLE_SIZE)
392 
393 #define BOOST_FUSION_DEFINE_TPL_STRUCT_CTOR(                                    \
394     TEMPLATE_PARAMS_SEQ, NAME, ATTRIBUTES_SEQ, ATTRIBUTE_TUPLE_SIZE)            \
395                                                                                 \
396     BOOST_PP_IF(BOOST_PP_DEC(BOOST_PP_SEQ_SIZE(ATTRIBUTES_SEQ)),                \
397         BOOST_FUSION_DEFINE_TPL_STRUCT_CTOR_N,                                  \
398         BOOST_FUSION_DEFINE_TPL_STRUCT_CTOR_1)(                                 \
399             TEMPLATE_PARAMS_SEQ, NAME, ATTRIBUTES_SEQ, ATTRIBUTE_TUPLE_SIZE)
400 
401 #define BOOST_FUSION_DEFINE_NONEMPTY_STRUCT_IMPL(                               \
402     NAME, ATTRIBUTES_SEQ, ATTRIBUTE_TUPLE_SIZE)                                 \
403                                                                                 \
404         BOOST_FUSION_DEFINE_STRUCT_IMPL_IMPL(                                   \
405             NAME, BOOST_PP_SEQ_TAIL(ATTRIBUTES_SEQ), ATTRIBUTE_TUPLE_SIZE)      \
406                                                                                 \
407         BOOST_FUSION_DEFINE_STRUCT_CTOR(                                        \
408             NAME, BOOST_PP_SEQ_TAIL(ATTRIBUTES_SEQ), ATTRIBUTE_TUPLE_SIZE)
409 
410 #define BOOST_FUSION_DEFINE_EMPTY_STRUCT_IMPL(                                  \
411     NAME, ATTRIBUTES_SEQ, ATTRIBUTE_TUPLE_SIZE)
412 
413 #define BOOST_FUSION_DEFINE_STRUCT_IMPL(                                        \
414     NAMESPACE_SEQ, NAME, ATTRIBUTES_SEQ, ATTRIBUTE_TUPLE_SIZE)                  \
415                                                                                 \
416     BOOST_FUSION_ADAPT_STRUCT_NAMESPACE_DEFINITION_BEGIN(NAMESPACE_SEQ)         \
417                                                                                 \
418     struct NAME                                                                 \
419     {                                                                           \
420         typedef NAME self_type;                                                 \
421                                                                                 \
422         BOOST_PP_IF(BOOST_PP_DEC(BOOST_PP_SEQ_SIZE(ATTRIBUTES_SEQ)),            \
423             BOOST_FUSION_DEFINE_NONEMPTY_STRUCT_IMPL,                           \
424             BOOST_FUSION_DEFINE_EMPTY_STRUCT_IMPL)(                             \
425                 NAME, ATTRIBUTES_SEQ, ATTRIBUTE_TUPLE_SIZE)                     \
426     };                                                                          \
427                                                                                 \
428     BOOST_FUSION_ADAPT_STRUCT_NAMESPACE_DEFINITION_END(NAMESPACE_SEQ)
429 
430 #define BOOST_FUSION_DEFINE_NONEMPTY_TPL_STRUCT_IMPL(                           \
431     TEMPLATE_PARAMS_SEQ, NAME, ATTRIBUTES_SEQ, ATTRIBUTE_TUPLE_SIZE)            \
432                                                                                 \
433         BOOST_FUSION_DEFINE_STRUCT_IMPL_IMPL(                                   \
434             NAME, BOOST_PP_SEQ_TAIL(ATTRIBUTES_SEQ), ATTRIBUTE_TUPLE_SIZE)      \
435                                                                                 \
436         BOOST_FUSION_DEFINE_TPL_STRUCT_CTOR(                                    \
437             TEMPLATE_PARAMS_SEQ,                                                \
438             NAME,                                                               \
439             BOOST_PP_SEQ_TAIL(ATTRIBUTES_SEQ),                                  \
440             ATTRIBUTE_TUPLE_SIZE)
441 
442 #define BOOST_FUSION_DEFINE_EMPTY_TPL_STRUCT_IMPL(                              \
443     TEMPLATE_PARAMS_SEQ, NAME, ATTRIBUTES_SEQ, ATTRIBUTE_TUPLE_SIZE)
444 
445 #define BOOST_FUSION_DEFINE_TPL_STRUCT_IMPL(                                    \
446     TEMPLATE_PARAMS_SEQ,                                                        \
447     NAMESPACE_SEQ,                                                              \
448     NAME,                                                                       \
449     ATTRIBUTES_SEQ,                                                             \
450     ATTRIBUTE_TUPLE_SIZE)                                                       \
451                                                                                 \
452     BOOST_FUSION_ADAPT_STRUCT_NAMESPACE_DEFINITION_BEGIN(NAMESPACE_SEQ)         \
453                                                                                 \
454     template<                                                                   \
455         BOOST_FUSION_ADAPT_STRUCT_UNPACK_TEMPLATE_PARAMS_IMPL(                  \
456             (0)TEMPLATE_PARAMS_SEQ)                                             \
457     >                                                                           \
458     struct NAME                                                                 \
459     {                                                                           \
460         typedef NAME self_type;                                                 \
461                                                                                 \
462         BOOST_PP_IF(BOOST_PP_DEC(BOOST_PP_SEQ_SIZE(ATTRIBUTES_SEQ)),            \
463             BOOST_FUSION_DEFINE_NONEMPTY_TPL_STRUCT_IMPL,                       \
464             BOOST_FUSION_DEFINE_EMPTY_TPL_STRUCT_IMPL)(                         \
465                 TEMPLATE_PARAMS_SEQ, NAME, ATTRIBUTES_SEQ, ATTRIBUTE_TUPLE_SIZE)\
466     };                                                                          \
467                                                                                 \
468     BOOST_FUSION_ADAPT_STRUCT_NAMESPACE_DEFINITION_END(NAMESPACE_SEQ)
469 
470 namespace boost { namespace fusion { namespace detail
471 {
472     template<typename A1, typename A2>
473     struct get_first_arg
474     {
475         typedef A1 type;
476     };
477 }}}
478 
479 #endif
480