source: NonGTP/Boost/boost/spirit/fusion/sequence/detail/tuple_macro.hpp @ 857

Revision 857, 5.1 KB checked in by igarcia, 18 years ago (diff)
Line 
1/*=============================================================================
2    Copyright (c) 2001-2003 Joel de Guzman
3
4    Use, modification and distribution is subject to the Boost Software
5    License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
6    http://www.boost.org/LICENSE_1_0.txt)
7==============================================================================*/
8#if !defined(FUSION_SEQUENCE_DETAIL_TUPLE_MACRO_HPP)
9#define FUSION_SEQUENCE_DETAIL_TUPLE_MACRO_HPP
10
11///////////////////////////////////////////////////////////////////////////////
12//
13//  Pre-processor gunk. See tuple10.hpp and detail/tuple10.hpp. The
14//  following code is the preprocessor version of the code found in
15//  those files, plus/minus a few specific details (specifically,
16//  the tuple_access<N> and tupleN+1 classes).
17//
18///////////////////////////////////////////////////////////////////////////////
19#include <boost/preprocessor/cat.hpp>
20#include <boost/preprocessor/repetition/repeat.hpp>
21#include <boost/preprocessor/repetition/enum_params.hpp>
22#include <boost/preprocessor/repetition/enum_binary_params.hpp>
23#include <boost/preprocessor/arithmetic/inc.hpp>
24#include <boost/preprocessor/arithmetic/dec.hpp>
25#include <boost/preprocessor/repetition/repeat_from_to.hpp>
26#include <boost/preprocessor/repetition/enum.hpp>
27
28#define FUSION_TUPLE_N_ACCESS(z, n, _)                                          \
29                                                                                \
30    template <>                                                                 \
31    struct tuple_access<n>                                                      \
32    {                                                                           \
33        template <typename Tuple>                                               \
34        static typename tuple_access_result<Tuple, n>::type                     \
35        get(Tuple& t)                                                           \
36        {                                                                       \
37            FUSION_RETURN_TUPLE_MEMBER(n);                                      \
38        }                                                                       \
39    };
40
41#define FUSION_TUPLE_MEMBER_DEFAULT_INIT(z, n, _)                               \
42    BOOST_PP_CAT(m, n)(BOOST_PP_CAT(T, n)())
43
44#define FUSION_TUPLE_MEMBER_INIT(z, n, _)                                       \
45    BOOST_PP_CAT(m, n)(BOOST_PP_CAT(_, n))
46
47#define FUSION_TUPLE_MEMBER_ITERATOR_INIT(z, n, _)                              \
48    BOOST_PP_CAT(m, n)(*BOOST_PP_CAT(_, n))
49
50#define FUSION_TUPLE_MEMBER(z, n, _)                                            \
51    BOOST_PP_CAT(T, n) BOOST_PP_CAT(m, n);
52
53#define FUSION_TUPLE_MEMBER_ASSIGN(z, n, _)                                     \
54    this->BOOST_PP_CAT(m, n) = t.BOOST_PP_CAT(m, n);
55
56#define FUSION_TUPLE_RESULT_OF_NEXT_TYPE(z, n, _)                               \
57    typedef typename meta::next<                                            \
58        BOOST_PP_CAT(BOOST_PP_CAT(i, n), _type)>::type                          \
59        BOOST_PP_CAT(BOOST_PP_CAT(i, BOOST_PP_INC(n)), _type);
60
61#if BOOST_WORKAROUND(__BORLANDC__, <= 0x551)
62# define FUSION_TUPLE_RESULT_OF_NEXT(z, n, _)                                   \
63    next_iter::BOOST_PP_CAT(BOOST_PP_CAT(i, BOOST_PP_INC(n)), _type)            \
64        BOOST_PP_CAT(i, BOOST_PP_INC(n))(fusion::next(BOOST_PP_CAT(i, n)));
65#else
66# define FUSION_TUPLE_RESULT_OF_NEXT(z, n, _)                                   \
67    FUSION_TUPLE_RESULT_OF_NEXT_TYPE(z, n, _)                                   \
68        BOOST_PP_CAT(BOOST_PP_CAT(i, BOOST_PP_INC(n)), _type)                   \
69            BOOST_PP_CAT(i, BOOST_PP_INC(n))(fusion::next(BOOST_PP_CAT(i, n)));
70#endif
71
72#if BOOST_WORKAROUND(__BORLANDC__, <= 0x551)
73# define FUSION_TUPLE_NEXT_ITER_N(z, n, _)                                      \
74    namespace detail                                                            \
75    {                                                                           \
76        template <typename i0_type>                                             \
77        struct BOOST_PP_CAT(next_iter, n)                                       \
78        {                                                                       \
79            BOOST_PP_REPEAT(                                                    \
80                BOOST_PP_DEC(n), FUSION_TUPLE_RESULT_OF_NEXT_TYPE, _)           \
81        };                                                                      \
82    }
83
84#else
85# define FUSION_TUPLE_NEXT_ITER_N(z, n, _)
86#endif
87
88#if BOOST_WORKAROUND(__BORLANDC__, <= 0x551)
89# define FUSION_TUPLE_CONSTRUCT_FROM_ITER(n)                                    \
90    typedef detail::BOOST_PP_CAT(next_iter, n)<i0_type> next_iter;              \
91    BOOST_PP_REPEAT(BOOST_PP_DEC(n), FUSION_TUPLE_RESULT_OF_NEXT, _)
92#else
93# define FUSION_TUPLE_CONSTRUCT_FROM_ITER(n)                                    \
94    BOOST_PP_REPEAT(BOOST_PP_DEC(n), FUSION_TUPLE_RESULT_OF_NEXT, _)
95#endif
96
97#endif
Note: See TracBrowser for help on using the repository browser.