1 | |
---|
2 | #ifndef BOOST_MPL_AUX_INSERTER_ALGORITHM_HPP_INCLUDED |
---|
3 | #define BOOST_MPL_AUX_INSERTER_ALGORITHM_HPP_INCLUDED |
---|
4 | |
---|
5 | // Copyright Aleksey Gurtovoy 2003-2004 |
---|
6 | // Copyright David Abrahams 2003-2004 |
---|
7 | // |
---|
8 | // Distributed under the Boost Software License, Version 1.0. |
---|
9 | // (See accompanying file LICENSE_1_0.txt or copy at |
---|
10 | // http://www.boost.org/LICENSE_1_0.txt) |
---|
11 | // |
---|
12 | // See http://www.boost.org/libs/mpl for documentation. |
---|
13 | |
---|
14 | // $Id$ |
---|
15 | // $Date: 2009-08-18 01:16:53 -0400 (Tue, 18 Aug 2009) $ |
---|
16 | // $Revision: 55648 $ |
---|
17 | |
---|
18 | #include <boost/mpl/back_inserter.hpp> |
---|
19 | #include <boost/mpl/front_inserter.hpp> |
---|
20 | #include <boost/mpl/push_back.hpp> |
---|
21 | #include <boost/mpl/push_front.hpp> |
---|
22 | #include <boost/mpl/back_inserter.hpp> |
---|
23 | #include <boost/mpl/front_inserter.hpp> |
---|
24 | #include <boost/mpl/clear.hpp> |
---|
25 | #include <boost/mpl/eval_if.hpp> |
---|
26 | #include <boost/mpl/if.hpp> |
---|
27 | #include <boost/mpl/aux_/na.hpp> |
---|
28 | #include <boost/mpl/aux_/common_name_wknd.hpp> |
---|
29 | #include <boost/mpl/aux_/na_spec.hpp> |
---|
30 | #include <boost/mpl/aux_/preprocessor/params.hpp> |
---|
31 | #include <boost/mpl/aux_/preprocessor/default_params.hpp> |
---|
32 | #include <boost/mpl/aux_/config/ctps.hpp> |
---|
33 | |
---|
34 | #include <boost/preprocessor/arithmetic/dec.hpp> |
---|
35 | |
---|
36 | #if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) |
---|
37 | |
---|
38 | # define BOOST_MPL_AUX_INSERTER_ALGORITHM_DEF(arity, name) \ |
---|
39 | BOOST_MPL_AUX_COMMON_NAME_WKND(name) \ |
---|
40 | template< \ |
---|
41 | BOOST_MPL_PP_DEFAULT_PARAMS(arity, typename P, na) \ |
---|
42 | > \ |
---|
43 | struct name \ |
---|
44 | : aux::name##_impl<BOOST_MPL_PP_PARAMS(arity, P)> \ |
---|
45 | { \ |
---|
46 | }; \ |
---|
47 | \ |
---|
48 | template< \ |
---|
49 | BOOST_MPL_PP_PARAMS(BOOST_PP_DEC(arity), typename P) \ |
---|
50 | > \ |
---|
51 | struct name< BOOST_MPL_PP_PARAMS(BOOST_PP_DEC(arity), P),na > \ |
---|
52 | : if_< has_push_back< typename clear<P1>::type> \ |
---|
53 | , aux::name##_impl< \ |
---|
54 | BOOST_MPL_PP_PARAMS(BOOST_PP_DEC(arity), P) \ |
---|
55 | , back_inserter< typename clear<P1>::type > \ |
---|
56 | > \ |
---|
57 | , aux::reverse_##name##_impl< \ |
---|
58 | BOOST_MPL_PP_PARAMS(BOOST_PP_DEC(arity), P) \ |
---|
59 | , front_inserter< typename clear<P1>::type > \ |
---|
60 | > \ |
---|
61 | >::type \ |
---|
62 | { \ |
---|
63 | }; \ |
---|
64 | \ |
---|
65 | template< \ |
---|
66 | BOOST_MPL_PP_DEFAULT_PARAMS(arity, typename P, na) \ |
---|
67 | > \ |
---|
68 | struct reverse_##name \ |
---|
69 | : aux::reverse_##name##_impl<BOOST_MPL_PP_PARAMS(arity, P)> \ |
---|
70 | { \ |
---|
71 | }; \ |
---|
72 | \ |
---|
73 | template< \ |
---|
74 | BOOST_MPL_PP_PARAMS(BOOST_PP_DEC(arity), typename P) \ |
---|
75 | > \ |
---|
76 | struct reverse_##name< BOOST_MPL_PP_PARAMS(BOOST_PP_DEC(arity), P),na > \ |
---|
77 | : if_< has_push_back<P1> \ |
---|
78 | , aux::reverse_##name##_impl< \ |
---|
79 | BOOST_MPL_PP_PARAMS(BOOST_PP_DEC(arity), P) \ |
---|
80 | , back_inserter< typename clear<P1>::type > \ |
---|
81 | > \ |
---|
82 | , aux::name##_impl< \ |
---|
83 | BOOST_MPL_PP_PARAMS(BOOST_PP_DEC(arity), P) \ |
---|
84 | , front_inserter< typename clear<P1>::type > \ |
---|
85 | > \ |
---|
86 | >::type \ |
---|
87 | { \ |
---|
88 | }; \ |
---|
89 | BOOST_MPL_AUX_NA_SPEC(arity, name) \ |
---|
90 | BOOST_MPL_AUX_NA_SPEC(arity, reverse_##name) \ |
---|
91 | /**/ |
---|
92 | |
---|
93 | #else |
---|
94 | |
---|
95 | # define BOOST_MPL_AUX_INSERTER_ALGORITHM_DEF(arity, name) \ |
---|
96 | BOOST_MPL_AUX_COMMON_NAME_WKND(name) \ |
---|
97 | template< \ |
---|
98 | BOOST_MPL_PP_PARAMS(BOOST_PP_DEC(arity), typename P) \ |
---|
99 | > \ |
---|
100 | struct def_##name##_impl \ |
---|
101 | : if_< has_push_back<P1> \ |
---|
102 | , aux::name##_impl< \ |
---|
103 | BOOST_MPL_PP_PARAMS(BOOST_PP_DEC(arity), P) \ |
---|
104 | , back_inserter< typename clear<P1>::type > \ |
---|
105 | > \ |
---|
106 | , aux::reverse_##name##_impl< \ |
---|
107 | BOOST_MPL_PP_PARAMS(BOOST_PP_DEC(arity), P) \ |
---|
108 | , front_inserter< typename clear<P1>::type > \ |
---|
109 | > \ |
---|
110 | >::type \ |
---|
111 | { \ |
---|
112 | }; \ |
---|
113 | \ |
---|
114 | template< \ |
---|
115 | BOOST_MPL_PP_DEFAULT_PARAMS(arity, typename P, na) \ |
---|
116 | > \ |
---|
117 | struct name \ |
---|
118 | { \ |
---|
119 | typedef typename eval_if< \ |
---|
120 | is_na<BOOST_PP_CAT(P, arity)> \ |
---|
121 | , def_##name##_impl<BOOST_MPL_PP_PARAMS(BOOST_PP_DEC(arity), P)> \ |
---|
122 | , aux::name##_impl<BOOST_MPL_PP_PARAMS(arity, P)> \ |
---|
123 | >::type type; \ |
---|
124 | }; \ |
---|
125 | \ |
---|
126 | template< \ |
---|
127 | BOOST_MPL_PP_PARAMS(BOOST_PP_DEC(arity), typename P) \ |
---|
128 | > \ |
---|
129 | struct def_reverse_##name##_impl \ |
---|
130 | : if_< has_push_back<P1> \ |
---|
131 | , aux::reverse_##name##_impl< \ |
---|
132 | BOOST_MPL_PP_PARAMS(BOOST_PP_DEC(arity), P) \ |
---|
133 | , back_inserter< typename clear<P1>::type > \ |
---|
134 | > \ |
---|
135 | , aux::name##_impl< \ |
---|
136 | BOOST_MPL_PP_PARAMS(BOOST_PP_DEC(arity), P) \ |
---|
137 | , front_inserter< typename clear<P1>::type > \ |
---|
138 | > \ |
---|
139 | >::type \ |
---|
140 | { \ |
---|
141 | }; \ |
---|
142 | template< \ |
---|
143 | BOOST_MPL_PP_DEFAULT_PARAMS(arity, typename P, na) \ |
---|
144 | > \ |
---|
145 | struct reverse_##name \ |
---|
146 | { \ |
---|
147 | typedef typename eval_if< \ |
---|
148 | is_na<BOOST_PP_CAT(P, arity)> \ |
---|
149 | , def_reverse_##name##_impl<BOOST_MPL_PP_PARAMS(BOOST_PP_DEC(arity), P)> \ |
---|
150 | , aux::reverse_##name##_impl<BOOST_MPL_PP_PARAMS(arity, P)> \ |
---|
151 | >::type type; \ |
---|
152 | }; \ |
---|
153 | BOOST_MPL_AUX_NA_SPEC(arity, name) \ |
---|
154 | BOOST_MPL_AUX_NA_SPEC(arity, reverse_##name) \ |
---|
155 | /**/ |
---|
156 | |
---|
157 | #endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION |
---|
158 | |
---|
159 | #endif // BOOST_MPL_AUX_INSERTER_ALGORITHM_HPP_INCLUDED |
---|