1 | /*=============================================================================
|
---|
2 | Copyright (c) 2003 Joel de Guzman
|
---|
3 | Copyright (c) 2004 Peder Holt
|
---|
4 |
|
---|
5 | Use, modification and distribution is subject to the Boost Software
|
---|
6 | License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
---|
7 | http://www.boost.org/LICENSE_1_0.txt)
|
---|
8 | ==============================================================================*/
|
---|
9 | #if !defined(FUSION_SEQUENCE_DETAIL_TUPLE_BEGIN_END_TRAITS_HPP)
|
---|
10 | #define FUSION_SEQUENCE_DETAIL_TUPLE_BEGIN_END_TRAITS_HPP
|
---|
11 |
|
---|
12 | #include <boost/spirit/fusion/detail/config.hpp>
|
---|
13 |
|
---|
14 | namespace boost { namespace fusion
|
---|
15 | {
|
---|
16 | struct tuple_tag;
|
---|
17 |
|
---|
18 | template <int N, typename Tuple>
|
---|
19 | struct tuple_iterator;
|
---|
20 |
|
---|
21 | namespace tuple_detail
|
---|
22 | {
|
---|
23 | template <typename Tuple>
|
---|
24 | struct begin_traits_impl
|
---|
25 | {
|
---|
26 | typedef tuple_iterator<0, Tuple> type;
|
---|
27 |
|
---|
28 | static type
|
---|
29 | call(Tuple& t);
|
---|
30 | };
|
---|
31 |
|
---|
32 | template <typename Tuple>
|
---|
33 | inline typename begin_traits_impl<Tuple>::type
|
---|
34 | begin_traits_impl<Tuple>::call(Tuple& t)
|
---|
35 | {
|
---|
36 | return type(t);
|
---|
37 | }
|
---|
38 |
|
---|
39 | template <typename Tuple>
|
---|
40 | struct end_traits_impl
|
---|
41 | {
|
---|
42 | typedef typename Tuple::size size;
|
---|
43 | typedef tuple_iterator<FUSION_GET_VALUE(size), Tuple> type;
|
---|
44 |
|
---|
45 | static type
|
---|
46 | call(Tuple& t);
|
---|
47 | };
|
---|
48 |
|
---|
49 | template <typename Tuple>
|
---|
50 | inline typename end_traits_impl<Tuple>::type
|
---|
51 | end_traits_impl<Tuple>::call(Tuple& t)
|
---|
52 | {
|
---|
53 | return type(t);
|
---|
54 | }
|
---|
55 | }
|
---|
56 |
|
---|
57 | namespace meta
|
---|
58 | {
|
---|
59 | template <typename Tag>
|
---|
60 | struct begin_impl;
|
---|
61 |
|
---|
62 | template <>
|
---|
63 | struct begin_impl<tuple_tag>
|
---|
64 | {
|
---|
65 | template <typename Tuple>
|
---|
66 | struct apply : tuple_detail::begin_traits_impl<Tuple> {};
|
---|
67 | };
|
---|
68 |
|
---|
69 | template <typename Tag>
|
---|
70 | struct end_impl;
|
---|
71 |
|
---|
72 | template <>
|
---|
73 | struct end_impl<tuple_tag>
|
---|
74 | {
|
---|
75 | template <typename Tuple>
|
---|
76 | struct apply : tuple_detail::end_traits_impl<Tuple> {};
|
---|
77 | };
|
---|
78 | }
|
---|
79 | }}
|
---|
80 |
|
---|
81 | #include <boost/mpl/begin_end.hpp>
|
---|
82 | #include <boost/mpl/clear.hpp>
|
---|
83 | #include <boost/mpl/insert.hpp>
|
---|
84 | #include <boost/mpl/empty.hpp>
|
---|
85 | #include <boost/spirit/fusion/sequence/tuple_forward.hpp>
|
---|
86 |
|
---|
87 | namespace boost { namespace fusion { namespace meta
|
---|
88 | {
|
---|
89 | template <typename Sequence>
|
---|
90 | struct generate;
|
---|
91 |
|
---|
92 | template <typename Sequence, typename T>
|
---|
93 | struct push_front;
|
---|
94 | }}}
|
---|
95 |
|
---|
96 | namespace boost { namespace mpl
|
---|
97 | {
|
---|
98 | // these mpl traits really ought to be placed somewhere else
|
---|
99 |
|
---|
100 | template <typename Tag>
|
---|
101 | struct begin_impl;
|
---|
102 |
|
---|
103 | template <>
|
---|
104 | struct begin_impl<fusion::tuple_tag>
|
---|
105 | : fusion::meta::begin_impl<fusion::tuple_tag> {};
|
---|
106 |
|
---|
107 | template <typename Tag>
|
---|
108 | struct end_impl;
|
---|
109 |
|
---|
110 | template <>
|
---|
111 | struct end_impl<fusion::tuple_tag>
|
---|
112 | : fusion::meta::end_impl<fusion::tuple_tag> {};
|
---|
113 |
|
---|
114 | template <typename Tag>
|
---|
115 | struct clear_impl;
|
---|
116 |
|
---|
117 | template <>
|
---|
118 | struct clear_impl<fusion::tuple_tag>
|
---|
119 | {
|
---|
120 | template <typename Tuple>
|
---|
121 | struct apply
|
---|
122 | {
|
---|
123 | typedef fusion::tuple<> type;
|
---|
124 | };
|
---|
125 | };
|
---|
126 |
|
---|
127 | template <typename Tag>
|
---|
128 | struct push_front_impl;
|
---|
129 |
|
---|
130 | template <>
|
---|
131 | struct push_front_impl<fusion::tuple_tag>
|
---|
132 | {
|
---|
133 | template <typename Tuple, typename T>
|
---|
134 | struct apply
|
---|
135 | {
|
---|
136 | typedef typename fusion::meta::push_front<Tuple, T> func1_;
|
---|
137 | typedef typename fusion::meta::generate<FUSION_GET_TYPE(func1_)>::type
|
---|
138 | type;
|
---|
139 | };
|
---|
140 | };
|
---|
141 | }}
|
---|
142 |
|
---|
143 | #endif
|
---|