1 | // Copyright David Abrahams 2003. Use, modification and distribution is
|
---|
2 | // subject to the Boost Software License, Version 1.0. (See accompanying
|
---|
3 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
---|
4 |
|
---|
5 | // !!No include guards, intentionally!!
|
---|
6 |
|
---|
7 | #define N BOOST_PP_ITERATION()
|
---|
8 |
|
---|
9 | template <BOOST_PP_ENUM_PARAMS(N, typename T)>
|
---|
10 | struct BOOST_PP_CAT(tuple, N);
|
---|
11 |
|
---|
12 | template <BOOST_PP_ENUM_PARAMS(N, typename T)>
|
---|
13 | struct BOOST_PP_CAT(tuple_data, N)
|
---|
14 | : sequence_base<BOOST_PP_CAT(tuple, N)
|
---|
15 | <BOOST_PP_ENUM_PARAMS(N, T)> >
|
---|
16 | {
|
---|
17 | typedef mpl::BOOST_PP_CAT(vector, N)<BOOST_PP_ENUM_PARAMS(N, T)> types;
|
---|
18 | typedef tuple_tag tag;
|
---|
19 | typedef mpl::int_<N> size;
|
---|
20 | typedef BOOST_PP_CAT(tuple_data, N) identity_type;
|
---|
21 |
|
---|
22 | BOOST_PP_CAT(tuple_data, N)()
|
---|
23 | : BOOST_PP_ENUM(N, FUSION_TUPLE_MEMBER_DEFAULT_INIT, _) {}
|
---|
24 |
|
---|
25 | BOOST_PP_CAT(tuple_data, N)(BOOST_PP_ENUM_BINARY_PARAMS(
|
---|
26 | N, typename detail::call_param<T, >::type _))
|
---|
27 | : BOOST_PP_ENUM(N, FUSION_TUPLE_MEMBER_INIT, _) {}
|
---|
28 |
|
---|
29 | template <BOOST_PP_ENUM_PARAMS(N, typename A)>
|
---|
30 | BOOST_PP_CAT(tuple_data, N)(detail::disambiguate_as_iterator,
|
---|
31 | BOOST_PP_ENUM_BINARY_PARAMS(N, A, & _))
|
---|
32 | : BOOST_PP_ENUM(N, FUSION_TUPLE_MEMBER_ITERATOR_INIT, _) {}
|
---|
33 |
|
---|
34 | BOOST_PP_REPEAT(N, FUSION_TUPLE_MEMBER, _)
|
---|
35 | };
|
---|
36 |
|
---|
37 | template <BOOST_PP_ENUM_PARAMS(N, typename T)>
|
---|
38 | struct BOOST_PP_CAT(tuple, N)
|
---|
39 | : BOOST_PP_CAT(tuple_data, N)<BOOST_PP_ENUM_PARAMS(N, T)>
|
---|
40 | {
|
---|
41 | typedef BOOST_PP_CAT(tuple_data, N)<
|
---|
42 | BOOST_PP_ENUM_PARAMS(N, T)> base_type;
|
---|
43 |
|
---|
44 | BOOST_PP_CAT(tuple, N)()
|
---|
45 | : base_type()
|
---|
46 | {}
|
---|
47 |
|
---|
48 | BOOST_PP_CAT(tuple, N)(BOOST_PP_ENUM_BINARY_PARAMS(
|
---|
49 | N, typename detail::call_param<T, >::type _))
|
---|
50 | : base_type(BOOST_PP_ENUM_PARAMS(N, _))
|
---|
51 | {}
|
---|
52 |
|
---|
53 | template <typename X>
|
---|
54 | explicit BOOST_PP_CAT(tuple, N)(X const& x)
|
---|
55 | : base_type(construct(x, &x))
|
---|
56 | {}
|
---|
57 |
|
---|
58 | template <BOOST_PP_ENUM_PARAMS(N, typename U)>
|
---|
59 | BOOST_PP_CAT(tuple, N)&
|
---|
60 | operator=(BOOST_PP_CAT(tuple, N)<BOOST_PP_ENUM_PARAMS(N, U)> const& t)
|
---|
61 | {
|
---|
62 | BOOST_PP_REPEAT(N, FUSION_TUPLE_MEMBER_ASSIGN, _)
|
---|
63 | return *this;
|
---|
64 | }
|
---|
65 |
|
---|
66 | private:
|
---|
67 |
|
---|
68 | template <typename i0_type>
|
---|
69 | static base_type
|
---|
70 | construct(i0_type const& i0, void const*)
|
---|
71 | {
|
---|
72 | FUSION_TUPLE_CONSTRUCT_FROM_ITER(N)
|
---|
73 | return base_type(
|
---|
74 | detail::disambiguate_as_iterator(), BOOST_PP_ENUM_PARAMS(N, i));
|
---|
75 | }
|
---|
76 |
|
---|
77 | template <typename Tuple>
|
---|
78 | static base_type
|
---|
79 | construct(Tuple const& t, sequence_root const*)
|
---|
80 | {
|
---|
81 | return base_type(BOOST_PP_ENUM_PARAMS(N, t.m));
|
---|
82 | }
|
---|
83 | };
|
---|
84 |
|
---|
85 | #undef N
|
---|
86 |
|
---|