1 | /*============================================================================= |
---|
2 | Copyright (c) 1999-2003 Jaakko Järvi |
---|
3 | Copyright (c) 2001-2003 Joel de Guzman |
---|
4 | Copyright (c) 2004 Peder Holt |
---|
5 | |
---|
6 | Use, modification and distribution is subject to the Boost Software |
---|
7 | License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at |
---|
8 | http://www.boost.org/LICENSE_1_0.txt) |
---|
9 | ==============================================================================*/ |
---|
10 | #if !defined(FUSION_SEQUENCE_TUPLE_HPP) |
---|
11 | #define FUSION_SEQUENCE_TUPLE_HPP |
---|
12 | |
---|
13 | #include <utility> // for std::pair |
---|
14 | #include <boost/spirit/fusion/detail/access.hpp> |
---|
15 | #include <boost/spirit/fusion/sequence/detail/tuple_builder.hpp> |
---|
16 | #include <boost/preprocessor/repetition/enum_params.hpp> |
---|
17 | #include <boost/preprocessor/repetition/enum_params_with_a_default.hpp> |
---|
18 | #include <boost/preprocessor/repetition/repeat_from_to.hpp> |
---|
19 | #include <boost/spirit/fusion/sequence/tuple_forward.hpp> |
---|
20 | |
---|
21 | #define FUSION_TUPLE_CONSTRUCTOR(z, n, _) \ |
---|
22 | tuple(BOOST_PP_ENUM_BINARY_PARAMS( \ |
---|
23 | n, typename detail::call_param<T, >::type _)) \ |
---|
24 | : base_type(BOOST_PP_ENUM_PARAMS(n, _)) \ |
---|
25 | {} |
---|
26 | |
---|
27 | namespace boost { namespace fusion |
---|
28 | { |
---|
29 | struct void_t; |
---|
30 | |
---|
31 | template <BOOST_PP_ENUM_PARAMS(FUSION_MAX_TUPLE_SIZE, typename T)> |
---|
32 | struct tuple : |
---|
33 | detail::tuple_builder< |
---|
34 | BOOST_PP_ENUM_PARAMS(FUSION_MAX_TUPLE_SIZE, T) |
---|
35 | >::type |
---|
36 | { |
---|
37 | typedef |
---|
38 | typename detail::tuple_builder< |
---|
39 | BOOST_PP_ENUM_PARAMS(FUSION_MAX_TUPLE_SIZE, T) |
---|
40 | >::type |
---|
41 | base_type; |
---|
42 | |
---|
43 | tuple() |
---|
44 | : base_type() {} |
---|
45 | |
---|
46 | template <typename X> |
---|
47 | /*explicit*/ tuple(X const& x) |
---|
48 | : base_type(x) {} |
---|
49 | |
---|
50 | explicit tuple(typename detail::call_param<T0>::type _0) |
---|
51 | : base_type(_0) {} |
---|
52 | |
---|
53 | BOOST_PP_REPEAT_FROM_TO( |
---|
54 | 2, FUSION_MAX_TUPLE_SIZE, FUSION_TUPLE_CONSTRUCTOR, _) |
---|
55 | |
---|
56 | template <typename X> |
---|
57 | tuple& operator=(X const& other) |
---|
58 | { |
---|
59 | base() = other; |
---|
60 | return *this; |
---|
61 | } |
---|
62 | |
---|
63 | typedef detail::tuple_builder<BOOST_PP_ENUM_PARAMS(FUSION_MAX_TUPLE_SIZE, T)> builder; |
---|
64 | |
---|
65 | typedef typename builder::begin begin; |
---|
66 | typedef typename builder::end end; |
---|
67 | typedef typename builder::size size; |
---|
68 | |
---|
69 | base_type& base() { return *this; } |
---|
70 | base_type const& base() const { return *this; } |
---|
71 | }; |
---|
72 | }} |
---|
73 | |
---|
74 | #endif |
---|