fix doc example typo
[boost.git] / boost / proto / detail / deprecated.hpp
blobc8bcbb0b61eb7b58d78cdfeb1006cb7bd7e43d6f
1 ///////////////////////////////////////////////////////////////////////////////
2 /// \file deprecated.hpp
3 /// Definition of the deprecated BOOST_PROTO_DEFINE_FUCTION_TEMPLATE and
4 /// BOOST_PROTO_DEFINE_VARARG_FUCTION_TEMPLATE macros
5 //
6 // Copyright 2008 Eric Niebler. Distributed under the Boost
7 // Software License, Version 1.0. (See accompanying file
8 // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
10 #ifndef BOOST_PROTO_DETAIL_DEPRECATED_HPP_EAN_11_25_2008
11 #define BOOST_PROTO_DETAIL_DEPRECATED_HPP_EAN_11_25_2008
13 #include <boost/proto/detail/prefix.hpp>
14 #include <boost/preprocessor/cat.hpp>
15 #include <boost/preprocessor/facilities/intercept.hpp>
16 #include <boost/preprocessor/arithmetic/inc.hpp>
17 #include <boost/preprocessor/arithmetic/dec.hpp>
18 #include <boost/preprocessor/arithmetic/sub.hpp>
19 #include <boost/preprocessor/punctuation/comma_if.hpp>
20 #include <boost/preprocessor/control/if.hpp>
21 #include <boost/preprocessor/control/expr_if.hpp>
22 #include <boost/preprocessor/comparison/greater.hpp>
23 #include <boost/preprocessor/tuple/elem.hpp>
24 #include <boost/preprocessor/tuple/to_list.hpp>
25 #include <boost/preprocessor/logical/and.hpp>
26 #include <boost/preprocessor/seq/size.hpp>
27 #include <boost/preprocessor/seq/enum.hpp>
28 #include <boost/preprocessor/seq/seq.hpp>
29 #include <boost/preprocessor/seq/to_tuple.hpp>
30 #include <boost/preprocessor/seq/for_each_i.hpp>
31 #include <boost/preprocessor/seq/pop_back.hpp>
32 #include <boost/preprocessor/seq/push_back.hpp>
33 #include <boost/preprocessor/seq/push_front.hpp>
34 #include <boost/preprocessor/list/for_each_i.hpp>
35 #include <boost/preprocessor/repetition/repeat.hpp>
36 #include <boost/preprocessor/repetition/repeat_from_to.hpp>
37 #include <boost/preprocessor/repetition/enum_binary_params.hpp>
38 #include <boost/preprocessor/repetition/enum_trailing_binary_params.hpp>
39 #include <boost/proto/proto_fwd.hpp>
40 #include <boost/proto/detail/suffix.hpp>
42 /// INTERNAL ONLY
43 ///
44 #define BOOST_PROTO_VARARG_TEMPLATE_AUX_(R, DATA, I, ELEM) \
45 (ELEM BOOST_PP_CAT(BOOST_PP_CAT(X, DATA), BOOST_PP_CAT(_, I))) \
46 /**/
48 /// INTERNAL ONLY
49 ///
50 #define BOOST_PROTO_VARARG_TEMPLATE_YES_(R, DATA, I, ELEM) \
51 BOOST_PP_LIST_FOR_EACH_I_R( \
52 R \
53 , BOOST_PROTO_VARARG_TEMPLATE_AUX_ \
54 , I \
55 , BOOST_PP_TUPLE_TO_LIST( \
56 BOOST_PP_DEC(BOOST_PP_SEQ_SIZE(ELEM)) \
57 , BOOST_PP_SEQ_TO_TUPLE(BOOST_PP_SEQ_TAIL(ELEM)) \
58 ) \
59 ) \
60 /**/
62 /// INTERNAL ONLY
63 ///
64 #define BOOST_PROTO_VARARG_TEMPLATE_NO_(R, DATA, I, ELEM) \
65 /**/
67 /// INTERNAL ONLY
68 ///
69 #define BOOST_PROTO_VARARG_TEMPLATE_(R, DATA, I, ELEM) \
70 BOOST_PP_IF( \
71 BOOST_PP_DEC(BOOST_PP_SEQ_SIZE(ELEM)) \
72 , BOOST_PROTO_VARARG_TEMPLATE_YES_ \
73 , BOOST_PROTO_VARARG_TEMPLATE_NO_ \
74 )(R, DATA, I, ELEM) \
75 /**/
77 /// INTERNAL ONLY
78 ///
79 #define BOOST_PROTO_VARARG_TYPE_AUX_(R, DATA, I, ELEM) \
80 (BOOST_PP_CAT(BOOST_PP_CAT(X, DATA), BOOST_PP_CAT(_, I))) \
81 /**/
83 /// INTERNAL ONLY
84 ///
85 #define BOOST_PROTO_TEMPLATE_PARAMS_YES_(R, DATA, I, ELEM) \
86 < \
87 BOOST_PP_SEQ_ENUM( \
88 BOOST_PP_LIST_FOR_EACH_I_R( \
89 R \
90 , BOOST_PROTO_VARARG_TYPE_AUX_ \
91 , I \
92 , BOOST_PP_TUPLE_TO_LIST( \
93 BOOST_PP_DEC(BOOST_PP_SEQ_SIZE(ELEM)) \
94 , BOOST_PP_SEQ_TO_TUPLE(BOOST_PP_SEQ_TAIL(ELEM)) \
95 ) \
96 ) \
97 ) \
98 > \
99 /**/
101 /// INTERNAL ONLY
103 #define BOOST_PROTO_TEMPLATE_PARAMS_NO_(R, DATA, I, ELEM) \
104 /**/
106 /// INTERNAL ONLY
108 #define BOOST_PROTO_VARARG_TYPE_(R, DATA, I, ELEM) \
109 BOOST_PP_COMMA_IF(I) \
110 BOOST_PP_SEQ_HEAD(ELEM) \
111 BOOST_PP_IF( \
112 BOOST_PP_DEC(BOOST_PP_SEQ_SIZE(ELEM)) \
113 , BOOST_PROTO_TEMPLATE_PARAMS_YES_ \
114 , BOOST_PROTO_TEMPLATE_PARAMS_NO_ \
115 )(R, DATA, I, ELEM) BOOST_PP_EXPR_IF(BOOST_PP_GREATER(I, 1), const) \
116 /**/
118 /// INTERNAL ONLY
120 #define BOOST_PROTO_VARARG_AS_EXPR_(R, DATA, I, ELEM) \
121 BOOST_PP_EXPR_IF( \
122 BOOST_PP_GREATER(I, 1) \
123 , (( \
124 BOOST_PP_SEQ_HEAD(ELEM) \
125 BOOST_PP_IF( \
126 BOOST_PP_DEC(BOOST_PP_SEQ_SIZE(ELEM)) \
127 , BOOST_PROTO_TEMPLATE_PARAMS_YES_ \
128 , BOOST_PROTO_TEMPLATE_PARAMS_NO_ \
129 )(R, DATA, I, ELEM)() \
130 )) \
132 /**/
134 /// INTERNAL ONLY
136 #define BOOST_PROTO_VARARG_AS_CHILD_(Z, N, DATA) \
137 (BOOST_PP_CAT(DATA, N)) \
138 /**/
140 /// INTERNAL ONLY
142 #define BOOST_PROTO_SEQ_PUSH_FRONT(SEQ, ELEM) \
143 BOOST_PP_SEQ_POP_BACK(BOOST_PP_SEQ_PUSH_FRONT(BOOST_PP_SEQ_PUSH_BACK(SEQ, _dummy_), ELEM)) \
144 /**/
146 /// INTERNAL ONLY
148 #define BOOST_PROTO_VARARG_AS_PARAM_(Z, N, DATA) \
149 (BOOST_PP_CAT(DATA, N)) \
150 /**/
152 /// INTERNAL ONLY
154 #define BOOST_PROTO_VARARG_FUN_(Z, N, DATA) \
155 template< \
156 BOOST_PP_SEQ_ENUM( \
157 BOOST_PP_SEQ_FOR_EACH_I( \
158 BOOST_PROTO_VARARG_TEMPLATE_, ~ \
159 , BOOST_PP_SEQ_PUSH_FRONT( \
160 BOOST_PROTO_SEQ_PUSH_FRONT( \
161 BOOST_PP_TUPLE_ELEM(4, 2, DATA) \
162 , (BOOST_PP_TUPLE_ELEM(4, 3, DATA)) \
164 , BOOST_PP_TUPLE_ELEM(4, 1, DATA) \
167 BOOST_PP_REPEAT_ ## Z(N, BOOST_PROTO_VARARG_AS_PARAM_, typename A) \
170 typename boost::proto::result_of::make_expr< \
171 BOOST_PP_SEQ_FOR_EACH_I( \
172 BOOST_PROTO_VARARG_TYPE_, ~ \
173 , BOOST_PP_SEQ_PUSH_FRONT( \
174 BOOST_PROTO_SEQ_PUSH_FRONT( \
175 BOOST_PP_TUPLE_ELEM(4, 2, DATA) \
176 , (BOOST_PP_TUPLE_ELEM(4, 3, DATA)) \
178 , BOOST_PP_TUPLE_ELEM(4, 1, DATA) \
181 BOOST_PP_ENUM_TRAILING_BINARY_PARAMS_Z(Z, N, A, const & BOOST_PP_INTERCEPT) \
182 >::type const \
183 BOOST_PP_TUPLE_ELEM(4, 0, DATA)(BOOST_PP_ENUM_BINARY_PARAMS_Z(Z, N, A, const &a)) \
185 return boost::proto::detail::make_expr_< \
186 BOOST_PP_SEQ_FOR_EACH_I( \
187 BOOST_PROTO_VARARG_TYPE_, ~ \
188 , BOOST_PP_SEQ_PUSH_FRONT( \
189 BOOST_PROTO_SEQ_PUSH_FRONT( \
190 BOOST_PP_TUPLE_ELEM(4, 2, DATA) \
191 , (BOOST_PP_TUPLE_ELEM(4, 3, DATA)) \
193 , BOOST_PP_TUPLE_ELEM(4, 1, DATA) \
196 BOOST_PP_ENUM_TRAILING_BINARY_PARAMS_Z(Z, N, A, const & BOOST_PP_INTERCEPT) \
197 >()( \
198 BOOST_PP_SEQ_ENUM( \
199 BOOST_PP_SEQ_FOR_EACH_I( \
200 BOOST_PROTO_VARARG_AS_EXPR_, ~ \
201 , BOOST_PP_SEQ_PUSH_FRONT( \
202 BOOST_PROTO_SEQ_PUSH_FRONT( \
203 BOOST_PP_TUPLE_ELEM(4, 2, DATA) \
204 , (BOOST_PP_TUPLE_ELEM(4, 3, DATA)) \
206 , BOOST_PP_TUPLE_ELEM(4, 1, DATA) \
209 BOOST_PP_REPEAT_ ## Z(N, BOOST_PROTO_VARARG_AS_CHILD_, a) \
211 ); \
213 /**/
215 /// \code
216 /// BOOST_PROTO_DEFINE_FUNCTION_TEMPLATE(
217 /// 1
218 /// , construct
219 /// , boost::proto::default_domain
220 /// , (boost::proto::tag::function)
221 /// , ((op::construct)(typename)(int))
222 /// )
223 /// \endcode
224 #define BOOST_PROTO_DEFINE_FUNCTION_TEMPLATE(ARGCOUNT, NAME, DOMAIN, TAG, BOUNDARGS) \
225 BOOST_PP_REPEAT_FROM_TO( \
226 ARGCOUNT \
227 , BOOST_PP_INC(ARGCOUNT) \
228 , BOOST_PROTO_VARARG_FUN_ \
229 , (NAME, TAG, BOUNDARGS, DOMAIN) \
231 /**/
233 /// \code
234 /// BOOST_PROTO_DEFINE_VARARG_FUNCTION_TEMPLATE(
235 /// construct
236 /// , boost::proto::default_domain
237 /// , (boost::proto::tag::function)
238 /// , ((op::construct)(typename)(int))
239 /// )
240 /// \endcode
241 #define BOOST_PROTO_DEFINE_VARARG_FUNCTION_TEMPLATE(NAME, DOMAIN, TAG, BOUNDARGS) \
242 BOOST_PP_REPEAT( \
243 BOOST_PP_SUB(BOOST_PP_INC(BOOST_PROTO_MAX_ARITY), BOOST_PP_SEQ_SIZE(BOUNDARGS)) \
244 , BOOST_PROTO_VARARG_FUN_ \
245 , (NAME, TAG, BOUNDARGS, DOMAIN) \
247 /**/
249 #endif