1 /*=============================================================================
2 Copyright (c) 2001-2011 Joel de Guzman
4 Distributed under the Boost Software License, Version 1.0. (See accompanying
5 file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
6 ==============================================================================*/
7 // No include guard. This file is meant to be included many times
9 #if !defined(FUSION_MACRO_05042005)
10 #define FUSION_MACRO_05042005
12 #define FUSION_VECTOR_CTOR_DEFAULT_INIT(z, n, _) \
15 #define FUSION_VECTOR_CTOR_INIT(z, n, _) \
18 #define FUSION_VECTOR_MEMBER_CTOR_INIT(z, n, _) \
21 #define FUSION_VECTOR_CTOR_FORWARD(z, n, _) \
22 m##n(BOOST_FUSION_FWD_ELEM(T##n, other.m##n))
24 #define FUSION_VECTOR_CTOR_ARG_FWD(z, n, _) \
25 m##n(BOOST_FUSION_FWD_ELEM(U##n, _##n))
27 #define FUSION_VECTOR_MEMBER_DECL(z, n, _) \
30 #define FUSION_VECTOR_MEMBER_FORWARD(z, n, _) \
31 BOOST_FUSION_FWD_ELEM(U##n, _##n)
33 #define FUSION_VECTOR_MEMBER_ASSIGN(z, n, _) \
34 this->BOOST_PP_CAT(m, n) = vec.BOOST_PP_CAT(m, n);
36 #define FUSION_VECTOR_MEMBER_DEREF_ASSIGN(z, n, _) \
37 this->BOOST_PP_CAT(m, n) = *BOOST_PP_CAT(i, n);
39 #define FUSION_VECTOR_MEMBER_MOVE(z, n, _) \
40 this->BOOST_PP_CAT(m, n) = std::forward< \
41 BOOST_PP_CAT(T, n)>(vec.BOOST_PP_CAT(m, n));
43 #define FUSION_VECTOR_MEMBER_AT_IMPL(z, n, _) \
44 BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED \
45 typename add_reference<T##n>::type \
46 at_impl(mpl::int_<n>) { return this->m##n; } \
47 BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED \
48 typename add_reference<typename add_const<T##n>::type>::type \
49 at_impl(mpl::int_<n>) const { return this->m##n; }
51 #define FUSION_VECTOR_MEMBER_ITER_DECL_VAR(z, n, _) \
52 typedef typename result_of::next< \
53 BOOST_PP_CAT(I, BOOST_PP_DEC(n))>::type BOOST_PP_CAT(I, n); \
54 BOOST_PP_CAT(I, n) BOOST_PP_CAT(i, n) \
55 = fusion::next(BOOST_PP_CAT(i, BOOST_PP_DEC(n)));
59 #define N BOOST_PP_ITERATION()
61 template <BOOST_PP_ENUM_PARAMS(N, typename T)>
62 struct BOOST_PP_CAT(vector_data, N)
64 BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
65 BOOST_PP_CAT(vector_data, N)()
66 : BOOST_PP_ENUM(N, FUSION_VECTOR_CTOR_DEFAULT_INIT, _) {}
68 #if defined(__WAVE__) && defined(BOOST_FUSION_CREATE_PREPROCESSED_FILES)
69 FUSION_HASH if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
71 #if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) || \
72 (defined(__WAVE__) && defined(BOOST_FUSION_CREATE_PREPROCESSED_FILES))
73 template <BOOST_PP_ENUM_PARAMS(N, typename U)>
74 #if defined(__WAVE__) && defined(BOOST_FUSION_CREATE_PREPROCESSED_FILES)
75 FUSION_HASH if !defined(BOOST_CLANG)
79 #if !defined(BOOST_CLANG)
83 BOOST_FUSION_GPU_ENABLED
84 BOOST_PP_CAT(vector_data, N)(BOOST_PP_ENUM_BINARY_PARAMS(N, U, && arg)
85 , typename boost::enable_if<is_convertible<U0, T0> >::type* /*dummy*/ = 0
87 : BOOST_PP_ENUM(N, FUSION_VECTOR_CTOR_ARG_FWD, arg) {}
89 BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED
90 BOOST_PP_CAT(vector_data, N)(
91 BOOST_PP_CAT(vector_data, N)&& other)
92 : BOOST_PP_ENUM(N, FUSION_VECTOR_CTOR_FORWARD, arg) {}
94 #if defined(__WAVE__) && defined(BOOST_FUSION_CREATE_PREPROCESSED_FILES)
98 #if defined(__WAVE__) && defined(BOOST_FUSION_CREATE_PREPROCESSED_FILES)
99 FUSION_HASH if !defined(BOOST_CLANG)
103 #if !defined(BOOST_CLANG)
107 BOOST_FUSION_GPU_ENABLED
108 BOOST_PP_CAT(vector_data, N)(
109 BOOST_PP_ENUM_BINARY_PARAMS(
110 N, typename detail::call_param<T, >::type arg))
111 : BOOST_PP_ENUM(N, FUSION_VECTOR_CTOR_INIT, arg) {}
113 BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
114 BOOST_PP_CAT(vector_data, N)(
115 BOOST_PP_CAT(vector_data, N) const& other)
116 : BOOST_PP_ENUM(N, FUSION_VECTOR_MEMBER_CTOR_INIT, _) {}
118 BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED
119 BOOST_PP_CAT(vector_data, N)&
120 operator=(BOOST_PP_CAT(vector_data, N) const& vec)
122 BOOST_PP_REPEAT(N, FUSION_VECTOR_MEMBER_ASSIGN, _)
126 template <typename Sequence>
127 #if defined(__WAVE__) && defined(BOOST_FUSION_CREATE_PREPROCESSED_FILES)
128 FUSION_HASH if !defined(BOOST_CLANG)
129 BOOST_CXX14_CONSTEXPR
132 #if !defined(BOOST_CLANG)
133 BOOST_CXX14_CONSTEXPR
136 BOOST_FUSION_GPU_ENABLED
137 static BOOST_PP_CAT(vector_data, N)
138 init_from_sequence(Sequence const& seq)
140 typedef typename result_of::begin<Sequence const>::type I0;
141 I0 i0 = fusion::begin(seq);
142 BOOST_PP_REPEAT_FROM_TO(1, N, FUSION_VECTOR_MEMBER_ITER_DECL_VAR, _)
143 return BOOST_PP_CAT(vector_data, N)(BOOST_PP_ENUM_PARAMS(N, *i));
146 template <typename Sequence>
147 #if defined(__WAVE__) && defined(BOOST_FUSION_CREATE_PREPROCESSED_FILES)
148 FUSION_HASH if !defined(BOOST_CLANG)
149 BOOST_CXX14_CONSTEXPR
152 #if !defined(BOOST_CLANG)
153 BOOST_CXX14_CONSTEXPR
156 BOOST_FUSION_GPU_ENABLED
157 static BOOST_PP_CAT(vector_data, N)
158 init_from_sequence(Sequence& seq)
160 typedef typename result_of::begin<Sequence>::type I0;
161 I0 i0 = fusion::begin(seq);
162 BOOST_PP_REPEAT_FROM_TO(1, N, FUSION_VECTOR_MEMBER_ITER_DECL_VAR, _)
163 return BOOST_PP_CAT(vector_data, N)(BOOST_PP_ENUM_PARAMS(N, *i));
166 BOOST_PP_REPEAT(N, FUSION_VECTOR_MEMBER_DECL, _)
169 template <BOOST_PP_ENUM_PARAMS(N, typename T)>
170 struct BOOST_PP_CAT(vector, N)
171 : BOOST_PP_CAT(vector_data, N)<BOOST_PP_ENUM_PARAMS(N, T)>
172 , sequence_base<BOOST_PP_CAT(vector, N)<BOOST_PP_ENUM_PARAMS(N, T)> >
174 typedef BOOST_PP_CAT(vector, N)<BOOST_PP_ENUM_PARAMS(N, T)> this_type;
175 typedef BOOST_PP_CAT(vector_data, N)<BOOST_PP_ENUM_PARAMS(N, T)> base_type;
176 typedef mpl::BOOST_PP_CAT(vector, N)<BOOST_PP_ENUM_PARAMS(N, T)> types;
177 typedef vector_tag fusion_tag;
178 typedef fusion_sequence_tag tag; // this gets picked up by MPL
179 typedef mpl::false_ is_view;
180 typedef random_access_traversal_tag category;
181 typedef mpl::int_<N> size;
183 BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
184 BOOST_PP_CAT(vector, N)() {}
186 #if defined(__WAVE__) && defined(BOOST_FUSION_CREATE_PREPROCESSED_FILES)
187 FUSION_HASH if !defined(BOOST_CLANG)
191 #if !defined(BOOST_CLANG)
195 BOOST_FUSION_GPU_ENABLED
199 BOOST_PP_CAT(vector, N)(
200 BOOST_PP_ENUM_BINARY_PARAMS(
201 N, typename detail::call_param<T, >::type arg))
202 : base_type(BOOST_PP_ENUM_PARAMS(N, arg)) {}
204 #if defined(__WAVE__) && defined(BOOST_FUSION_CREATE_PREPROCESSED_FILES)
205 FUSION_HASH if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
207 #if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) || \
208 (defined(__WAVE__) && defined(BOOST_FUSION_CREATE_PREPROCESSED_FILES))
209 template <BOOST_PP_ENUM_PARAMS(N, typename U)>
210 #if defined(__WAVE__) && defined(BOOST_FUSION_CREATE_PREPROCESSED_FILES)
211 FUSION_HASH if !defined(BOOST_CLANG)
212 BOOST_CXX14_CONSTEXPR
215 #if !defined(BOOST_CLANG)
216 BOOST_CXX14_CONSTEXPR
219 BOOST_FUSION_GPU_ENABLED
222 BOOST_PP_CAT(vector, N)(U0&& _0
223 , typename boost::enable_if<is_convertible<U0, T0> >::type* /*dummy*/ = 0
225 : base_type(BOOST_FUSION_FWD_ELEM(U0, _0)) {}
227 BOOST_PP_CAT(vector, N)(BOOST_PP_ENUM_BINARY_PARAMS(N, U, && arg))
228 : base_type(BOOST_PP_ENUM(N, FUSION_VECTOR_MEMBER_FORWARD, arg)) {}
231 BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED
232 BOOST_PP_CAT(vector, N)(BOOST_PP_CAT(vector, N)&& rhs)
233 : base_type(std::forward<base_type>(rhs)) {}
235 BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
236 BOOST_PP_CAT(vector, N)(BOOST_PP_CAT(vector, N) const& rhs)
237 : base_type(static_cast<base_type const&>(rhs)) {}
239 BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED
240 BOOST_PP_CAT(vector, N)&
241 operator=(BOOST_PP_CAT(vector, N) const& vec)
243 base_type::operator=(vec);
247 BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED
248 BOOST_PP_CAT(vector, N)&
249 operator=(BOOST_PP_CAT(vector, N)&& vec)
251 BOOST_PP_REPEAT(N, FUSION_VECTOR_MEMBER_MOVE, _)
255 #if defined(__WAVE__) && defined(BOOST_FUSION_CREATE_PREPROCESSED_FILES)
259 template <BOOST_PP_ENUM_PARAMS(N, typename U)>
260 #if defined(__WAVE__) && defined(BOOST_FUSION_CREATE_PREPROCESSED_FILES)
261 FUSION_HASH if !defined(BOOST_CLANG)
262 BOOST_CXX14_CONSTEXPR
265 #if !defined(BOOST_CLANG)
266 BOOST_CXX14_CONSTEXPR
269 BOOST_FUSION_GPU_ENABLED
270 BOOST_PP_CAT(vector, N)(
271 BOOST_PP_CAT(vector, N)<BOOST_PP_ENUM_PARAMS(N, U)> const& vec)
272 : base_type(BOOST_PP_ENUM_PARAMS(N, vec.m)) {}
274 template <typename Sequence>
275 #if defined(__WAVE__) && defined(BOOST_FUSION_CREATE_PREPROCESSED_FILES)
276 FUSION_HASH if !defined(BOOST_CLANG)
277 BOOST_CXX14_CONSTEXPR
280 #if !defined(BOOST_CLANG)
281 BOOST_CXX14_CONSTEXPR
284 BOOST_FUSION_GPU_ENABLED
285 BOOST_PP_CAT(vector, N)(
287 , typename boost::enable_if<traits::is_sequence<Sequence> >::type* = 0
289 , typename boost::disable_if<is_convertible<Sequence, T0> >::type* /*dummy*/ = 0
292 : base_type(base_type::init_from_sequence(seq)) {}
294 template <typename Sequence>
295 #if defined(__WAVE__) && defined(BOOST_FUSION_CREATE_PREPROCESSED_FILES)
296 FUSION_HASH if !defined(BOOST_CLANG)
297 BOOST_CXX14_CONSTEXPR
300 #if !defined(BOOST_CLANG)
301 BOOST_CXX14_CONSTEXPR
304 BOOST_FUSION_GPU_ENABLED
305 BOOST_PP_CAT(vector, N)(
307 , typename boost::enable_if<traits::is_sequence<Sequence> >::type* = 0
309 , typename boost::disable_if<is_convertible<Sequence, T0> >::type* /*dummy*/ = 0
312 : base_type(base_type::init_from_sequence(seq)) {}
314 template <BOOST_PP_ENUM_PARAMS(N, typename U)>
315 BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED
316 BOOST_PP_CAT(vector, N)&
317 operator=(BOOST_PP_CAT(vector, N)<BOOST_PP_ENUM_PARAMS(N, U)> const& vec)
319 BOOST_PP_REPEAT(N, FUSION_VECTOR_MEMBER_ASSIGN, _)
323 template <typename Sequence>
324 BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED
325 typename boost::disable_if<is_convertible<Sequence, T0>, this_type&>::type
326 operator=(Sequence const& seq)
328 typedef typename result_of::begin<Sequence const>::type I0;
329 I0 i0 = fusion::begin(seq);
330 BOOST_PP_REPEAT_FROM_TO(1, N, FUSION_VECTOR_MEMBER_ITER_DECL_VAR, _)
331 BOOST_PP_REPEAT(N, FUSION_VECTOR_MEMBER_DEREF_ASSIGN, _)
335 BOOST_PP_REPEAT(N, FUSION_VECTOR_MEMBER_AT_IMPL, _)
338 BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED
339 typename add_reference<typename mpl::at<types, I>::type>::type
342 return this->at_impl(mpl::int_<I::value>());
346 BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
347 typename add_reference<typename add_const<typename mpl::at<types, I>::type>::type>::type
350 return this->at_impl(mpl::int_<I::value>());