]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | ////////////////////////////////////////////////////////////////////////////// |
2 | // | |
3 | // (C) Copyright Ion Gaztanaga 2015-2015. Distributed under the Boost | |
4 | // Software License, Version 1.0. (See accompanying file | |
5 | // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) | |
6 | // | |
7 | // See http://www.boost.org/libs/container for documentation. | |
8 | // | |
9 | ////////////////////////////////////////////////////////////////////////////// | |
10 | ||
11 | #ifndef BOOST_CONTAINER_DISPATCH_USES_ALLOCATOR_HPP | |
12 | #define BOOST_CONTAINER_DISPATCH_USES_ALLOCATOR_HPP | |
13 | ||
14 | #if defined (_MSC_VER) | |
15 | # pragma once | |
16 | #endif | |
17 | ||
18 | #include <boost/container/detail/config_begin.hpp> | |
19 | #include <boost/container/detail/workaround.hpp> | |
20 | ||
21 | #include <boost/container/allocator_traits.hpp> | |
22 | #include <boost/container/uses_allocator.hpp> | |
23 | ||
24 | #include <boost/container/detail/addressof.hpp> | |
25 | #include <boost/container/detail/mpl.hpp> | |
26 | #include <boost/container/detail/pair.hpp> | |
27 | #include <boost/container/detail/type_traits.hpp> | |
28 | ||
29 | #if defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) | |
30 | #include <boost/move/detail/fwd_macros.hpp> | |
31 | #endif | |
32 | #include <boost/move/utility_core.hpp> | |
33 | ||
34 | #include <boost/core/no_exceptions_support.hpp> | |
35 | ||
36 | namespace boost { namespace container { | |
37 | ||
38 | namespace container_detail { | |
39 | ||
40 | ||
41 | // Check if we can detect is_convertible using advanced SFINAE expressions | |
42 | #if !defined(BOOST_NO_CXX11_DECLTYPE) && !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) | |
43 | ||
44 | //! Code inspired by Mathias Gaunard's is_convertible.cpp found in the Boost mailing list | |
45 | //! http://boost.2283326.n4.nabble.com/type-traits-is-constructible-when-decltype-is-supported-td3575452.html | |
46 | //! Thanks Mathias! | |
47 | ||
48 | //With variadic templates, we need a single class to implement the trait | |
49 | template<class T, class ...Args> | |
50 | struct is_constructible | |
51 | { | |
52 | typedef char yes_type; | |
53 | struct no_type | |
54 | { char padding[2]; }; | |
55 | ||
56 | template<std::size_t N> | |
57 | struct dummy; | |
58 | ||
59 | template<class X> | |
60 | static decltype(X(boost::move_detail::declval<Args>()...), true_type()) test(int); | |
61 | ||
62 | template<class X> | |
63 | static no_type test(...); | |
64 | ||
65 | static const bool value = sizeof(test<T>(0)) == sizeof(yes_type); | |
66 | }; | |
67 | ||
68 | template <class T, class InnerAlloc, class ...Args> | |
69 | struct is_constructible_with_allocator_prefix | |
70 | : is_constructible<T, allocator_arg_t, InnerAlloc, Args...> | |
71 | {}; | |
72 | ||
73 | #else // #if !defined(BOOST_NO_SFINAE_EXPR) && !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) | |
74 | ||
75 | //Without advanced SFINAE expressions, we can't use is_constructible | |
76 | //so backup to constructible_with_allocator_xxx | |
77 | ||
78 | #if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) | |
79 | ||
80 | template <class T, class InnerAlloc, class ...Args> | |
81 | struct is_constructible_with_allocator_prefix | |
82 | : constructible_with_allocator_prefix<T> | |
83 | {}; | |
84 | ||
85 | template <class T, class InnerAlloc, class ...Args> | |
86 | struct is_constructible_with_allocator_suffix | |
87 | : constructible_with_allocator_suffix<T> | |
88 | {}; | |
89 | ||
90 | #else // #if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) | |
91 | ||
92 | template <class T, class InnerAlloc, BOOST_MOVE_CLASSDFLT9> | |
93 | struct is_constructible_with_allocator_prefix | |
94 | : constructible_with_allocator_prefix<T> | |
95 | {}; | |
96 | ||
97 | template <class T, class InnerAlloc, BOOST_MOVE_CLASSDFLT9> | |
98 | struct is_constructible_with_allocator_suffix | |
99 | : constructible_with_allocator_suffix<T> | |
100 | {}; | |
101 | ||
102 | #endif // #if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) | |
103 | ||
104 | #endif // #if !defined(BOOST_NO_SFINAE_EXPR) | |
105 | ||
106 | #if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) | |
107 | ||
108 | template < typename ConstructAlloc | |
109 | , typename ArgAlloc | |
110 | , typename T | |
111 | , class ...Args | |
112 | > | |
113 | inline typename container_detail::enable_if_and | |
114 | < void | |
115 | , container_detail::is_not_pair<T> | |
116 | , container_detail::not_< uses_allocator<T, ArgAlloc> > | |
117 | >::type dispatch_uses_allocator | |
118 | ( ConstructAlloc & construct_alloc, BOOST_FWD_REF(ArgAlloc) arg_alloc, T* p, BOOST_FWD_REF(Args)...args) | |
119 | { | |
120 | (void)arg_alloc; | |
121 | allocator_traits<ConstructAlloc>::construct(construct_alloc, p, ::boost::forward<Args>(args)...); | |
122 | } | |
123 | ||
124 | // allocator_arg_t | |
125 | template < typename ConstructAlloc | |
126 | , typename ArgAlloc | |
127 | , typename T | |
128 | , class ...Args | |
129 | > | |
130 | inline typename container_detail::enable_if_and | |
131 | < void | |
132 | , container_detail::is_not_pair<T> | |
133 | , uses_allocator<T, ArgAlloc> | |
134 | , is_constructible_with_allocator_prefix<T, ArgAlloc, Args...> | |
135 | >::type dispatch_uses_allocator | |
136 | ( ConstructAlloc& construct_alloc, BOOST_FWD_REF(ArgAlloc) arg_alloc, T* p, BOOST_FWD_REF(Args) ...args) | |
137 | { | |
138 | allocator_traits<ConstructAlloc>::construct | |
139 | ( construct_alloc, p, allocator_arg | |
140 | , ::boost::forward<ArgAlloc>(arg_alloc), ::boost::forward<Args>(args)...); | |
141 | } | |
142 | ||
143 | // allocator suffix | |
144 | template < typename ConstructAlloc | |
145 | , typename ArgAlloc | |
146 | , typename T | |
147 | , class ...Args | |
148 | > | |
149 | inline typename container_detail::enable_if_and | |
150 | < void | |
151 | , container_detail::is_not_pair<T> | |
152 | , uses_allocator<T, ArgAlloc> | |
153 | , container_detail::not_<is_constructible_with_allocator_prefix<T, ArgAlloc, Args...> > | |
154 | >::type dispatch_uses_allocator | |
155 | ( ConstructAlloc& construct_alloc, BOOST_FWD_REF(ArgAlloc) arg_alloc, T* p, BOOST_FWD_REF(Args)...args) | |
156 | { | |
157 | allocator_traits<ConstructAlloc>::construct | |
158 | (construct_alloc, p, ::boost::forward<Args>(args)..., ::boost::forward<ArgAlloc>(arg_alloc)); | |
159 | } | |
160 | ||
161 | #else //#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) | |
162 | ||
163 | #define BOOST_CONTAINER_SCOPED_ALLOCATOR_DISPATCH_USES_ALLOCATOR_CODE(N) \ | |
164 | template <typename ConstructAlloc, typename ArgAlloc, typename T BOOST_MOVE_I##N BOOST_MOVE_CLASS##N >\ | |
165 | inline typename container_detail::enable_if_and\ | |
166 | < void\ | |
167 | , container_detail::is_not_pair<T>\ | |
168 | , container_detail::not_<uses_allocator<T, ArgAlloc> >\ | |
169 | >::type\ | |
170 | dispatch_uses_allocator\ | |
171 | (ConstructAlloc &construct_alloc, BOOST_FWD_REF(ArgAlloc) arg_alloc, T* p BOOST_MOVE_I##N BOOST_MOVE_UREF##N)\ | |
172 | {\ | |
173 | (void)arg_alloc;\ | |
174 | allocator_traits<ConstructAlloc>::construct(construct_alloc, p BOOST_MOVE_I##N BOOST_MOVE_FWD##N);\ | |
175 | }\ | |
176 | // | |
177 | BOOST_MOVE_ITERATE_0TO9(BOOST_CONTAINER_SCOPED_ALLOCATOR_DISPATCH_USES_ALLOCATOR_CODE) | |
178 | #undef BOOST_CONTAINER_SCOPED_ALLOCATOR_DISPATCH_USES_ALLOCATOR_CODE | |
179 | ||
180 | #define BOOST_CONTAINER_SCOPED_ALLOCATOR_DISPATCH_USES_ALLOCATOR_CODE(N) \ | |
181 | template < typename ConstructAlloc, typename ArgAlloc, typename T BOOST_MOVE_I##N BOOST_MOVE_CLASS##N >\ | |
182 | inline typename container_detail::enable_if_and\ | |
183 | < void\ | |
184 | , container_detail::is_not_pair<T>\ | |
185 | , uses_allocator<T, ArgAlloc>\ | |
186 | , is_constructible_with_allocator_prefix<T, ArgAlloc BOOST_MOVE_I##N BOOST_MOVE_TARG##N>\ | |
187 | >::type\ | |
188 | dispatch_uses_allocator\ | |
189 | (ConstructAlloc& construct_alloc, BOOST_FWD_REF(ArgAlloc) arg_alloc, T* p BOOST_MOVE_I##N BOOST_MOVE_UREF##N)\ | |
190 | {\ | |
191 | allocator_traits<ConstructAlloc>::construct\ | |
192 | (construct_alloc, p, allocator_arg, ::boost::forward<ArgAlloc>(arg_alloc) BOOST_MOVE_I##N BOOST_MOVE_FWD##N);\ | |
193 | }\ | |
194 | // | |
195 | BOOST_MOVE_ITERATE_0TO9(BOOST_CONTAINER_SCOPED_ALLOCATOR_DISPATCH_USES_ALLOCATOR_CODE) | |
196 | #undef BOOST_CONTAINER_SCOPED_ALLOCATOR_DISPATCH_USES_ALLOCATOR_CODE | |
197 | ||
198 | #define BOOST_CONTAINER_SCOPED_ALLOCATOR_DISPATCH_USES_ALLOCATOR_CODE(N) \ | |
199 | template < typename ConstructAlloc, typename ArgAlloc, typename T BOOST_MOVE_I##N BOOST_MOVE_CLASS##N >\ | |
200 | inline typename container_detail::enable_if_and\ | |
201 | < void\ | |
202 | , container_detail::is_not_pair<T>\ | |
203 | , uses_allocator<T, ArgAlloc>\ | |
204 | , container_detail::not_<is_constructible_with_allocator_prefix<T, ArgAlloc BOOST_MOVE_I##N BOOST_MOVE_TARG##N> >\ | |
205 | >::type\ | |
206 | dispatch_uses_allocator\ | |
207 | (ConstructAlloc& construct_alloc, BOOST_FWD_REF(ArgAlloc) arg_alloc, T* p BOOST_MOVE_I##N BOOST_MOVE_UREF##N)\ | |
208 | {\ | |
209 | allocator_traits<ConstructAlloc>::construct\ | |
210 | (construct_alloc, p BOOST_MOVE_I##N BOOST_MOVE_FWD##N, ::boost::forward<ArgAlloc>(arg_alloc));\ | |
211 | }\ | |
212 | // | |
213 | BOOST_MOVE_ITERATE_0TO9(BOOST_CONTAINER_SCOPED_ALLOCATOR_DISPATCH_USES_ALLOCATOR_CODE) | |
214 | #undef BOOST_CONTAINER_SCOPED_ALLOCATOR_DISPATCH_USES_ALLOCATOR_CODE | |
215 | ||
216 | #endif //#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) | |
217 | ||
218 | template < typename ConstructAlloc | |
219 | , typename ArgAlloc | |
220 | , typename Pair | |
221 | > inline | |
222 | BOOST_CONTAINER_DOC1ST(void, typename container_detail::enable_if<container_detail::is_pair<Pair> >::type) | |
223 | dispatch_uses_allocator | |
224 | ( ConstructAlloc & construct_alloc | |
225 | , BOOST_FWD_REF(ArgAlloc) arg_alloc | |
226 | , Pair* p) | |
227 | { | |
228 | (dispatch_uses_allocator)(construct_alloc, arg_alloc, container_detail::addressof(p->first)); | |
229 | BOOST_TRY{ | |
230 | (dispatch_uses_allocator)(construct_alloc, arg_alloc, container_detail::addressof(p->second)); | |
231 | } | |
232 | BOOST_CATCH(...) { | |
233 | allocator_traits<ConstructAlloc>::destroy(construct_alloc, container_detail::addressof(p->first)); | |
234 | BOOST_RETHROW | |
235 | } | |
236 | BOOST_CATCH_END | |
237 | } | |
238 | ||
239 | ||
240 | template < typename ConstructAlloc | |
241 | , typename ArgAlloc | |
242 | , class Pair, class U, class V> | |
243 | BOOST_CONTAINER_DOC1ST(void, typename container_detail::enable_if<container_detail::is_pair<Pair> >::type) | |
244 | dispatch_uses_allocator | |
245 | ( ConstructAlloc & construct_alloc | |
246 | , BOOST_FWD_REF(ArgAlloc) arg_alloc | |
247 | , Pair* p, BOOST_FWD_REF(U) x, BOOST_FWD_REF(V) y) | |
248 | { | |
249 | (dispatch_uses_allocator)(construct_alloc, arg_alloc, container_detail::addressof(p->first), ::boost::forward<U>(x)); | |
250 | BOOST_TRY{ | |
251 | (dispatch_uses_allocator)(construct_alloc, arg_alloc, container_detail::addressof(p->second), ::boost::forward<V>(y)); | |
252 | } | |
253 | BOOST_CATCH(...){ | |
254 | allocator_traits<ConstructAlloc>::destroy(construct_alloc, container_detail::addressof(p->first)); | |
255 | BOOST_RETHROW | |
256 | } | |
257 | BOOST_CATCH_END | |
258 | } | |
259 | ||
260 | template < typename ConstructAlloc | |
261 | , typename ArgAlloc | |
262 | , class Pair, class Pair2> | |
263 | BOOST_CONTAINER_DOC1ST(void, typename container_detail::enable_if< container_detail::is_pair<Pair> >::type) | |
264 | dispatch_uses_allocator | |
265 | (ConstructAlloc & construct_alloc | |
266 | , BOOST_FWD_REF(ArgAlloc) arg_alloc | |
267 | , Pair* p, Pair2& x) | |
268 | { (dispatch_uses_allocator)(construct_alloc, arg_alloc, p, x.first, x.second); } | |
269 | ||
270 | template < typename ConstructAlloc | |
271 | , typename ArgAlloc | |
272 | , class Pair, class Pair2> | |
273 | typename container_detail::enable_if_and | |
274 | < void | |
275 | , container_detail::is_pair<Pair> | |
276 | , container_detail::not_<boost::move_detail::is_reference<Pair2> > >::type //This is needed for MSVC10 and ambiguous overloads | |
277 | dispatch_uses_allocator | |
278 | (ConstructAlloc & construct_alloc | |
279 | , BOOST_FWD_REF(ArgAlloc) arg_alloc | |
280 | , Pair* p, BOOST_RV_REF_BEG Pair2 BOOST_RV_REF_END x) | |
281 | { (dispatch_uses_allocator)(construct_alloc, arg_alloc, p, ::boost::move(x.first), ::boost::move(x.second)); } | |
282 | ||
283 | ||
284 | //piecewise construction from boost::tuple | |
285 | #define BOOST_DISPATCH_USES_ALLOCATOR_PIECEWISE_CONSTRUCT_BOOST_TUPLE_CODE(N,M)\ | |
286 | template< typename ConstructAlloc, typename ArgAlloc, class Pair \ | |
287 | , template<class, class, class, class, class, class, class, class, class, class> class BoostTuple \ | |
288 | BOOST_MOVE_I_IF(BOOST_MOVE_OR(N,M)) BOOST_MOVE_CLASS##N BOOST_MOVE_I_IF(BOOST_MOVE_AND(N,M)) BOOST_MOVE_CLASSQ##M > \ | |
289 | typename container_detail::enable_if< container_detail::is_pair<Pair> >::type\ | |
290 | dispatch_uses_allocator( ConstructAlloc & construct_alloc, ArgAlloc & arg_alloc, Pair* pair, piecewise_construct_t\ | |
291 | , BoostTuple<BOOST_MOVE_TARG##N BOOST_MOVE_I##N BOOST_MOVE_REPEAT(BOOST_MOVE_SUB(10,N),::boost::tuples::null_type)> p\ | |
292 | , BoostTuple<BOOST_MOVE_TARGQ##M BOOST_MOVE_I##M BOOST_MOVE_REPEAT(BOOST_MOVE_SUB(10,M),::boost::tuples::null_type)> q)\ | |
293 | {\ | |
294 | (void)p; (void)q;\ | |
295 | (dispatch_uses_allocator)\ | |
296 | (construct_alloc, arg_alloc, container_detail::addressof(pair->first) BOOST_MOVE_I_IF(N) BOOST_MOVE_TMPL_GET##N);\ | |
297 | BOOST_TRY{\ | |
298 | (dispatch_uses_allocator)\ | |
299 | (construct_alloc, arg_alloc, container_detail::addressof(pair->second) BOOST_MOVE_I_IF(M) BOOST_MOVE_TMPL_GETQ##M);\ | |
300 | }\ | |
301 | BOOST_CATCH(...) {\ | |
302 | allocator_traits<ConstructAlloc>::destroy(construct_alloc, container_detail::addressof(pair->first));\ | |
303 | BOOST_RETHROW\ | |
304 | }\ | |
305 | BOOST_CATCH_END\ | |
306 | }\ | |
307 | // | |
308 | BOOST_MOVE_ITER2D_0TOMAX(9, BOOST_DISPATCH_USES_ALLOCATOR_PIECEWISE_CONSTRUCT_BOOST_TUPLE_CODE) | |
309 | #undef BOOST_DISPATCH_USES_ALLOCATOR_PIECEWISE_CONSTRUCT_BOOST_TUPLE_CODE | |
310 | ||
311 | //piecewise construction from Std Tuple | |
312 | #if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) | |
313 | ||
314 | template< typename ConstructAlloc, typename ArgAlloc, class Pair | |
315 | , template<class ...> class Tuple, class... Args1, class... Args2, size_t... Indexes1, size_t... Indexes2> | |
316 | void dispatch_uses_allocator_index( ConstructAlloc & construct_alloc, ArgAlloc & arg_alloc, Pair* pair | |
317 | , Tuple<Args1...>& t1, Tuple<Args2...>& t2, index_tuple<Indexes1...>, index_tuple<Indexes2...>) | |
318 | { | |
319 | (void)t1; (void)t2; | |
320 | (dispatch_uses_allocator)(construct_alloc, arg_alloc, container_detail::addressof(pair->first), ::boost::forward<Args1>(get<Indexes1>(t1))...); | |
321 | BOOST_TRY{ | |
322 | (dispatch_uses_allocator)(construct_alloc, arg_alloc, container_detail::addressof(pair->second), ::boost::forward<Args2>(get<Indexes2>(t2))...); | |
323 | } | |
324 | BOOST_CATCH(...){ | |
325 | allocator_traits<ConstructAlloc>::destroy(construct_alloc, container_detail::addressof(pair->first)); | |
326 | BOOST_RETHROW | |
327 | } | |
328 | BOOST_CATCH_END | |
329 | } | |
330 | ||
331 | template< typename ConstructAlloc, typename ArgAlloc, class Pair | |
332 | , template<class ...> class Tuple, class... Args1, class... Args2> | |
333 | typename container_detail::enable_if< container_detail::is_pair<Pair> >::type | |
334 | dispatch_uses_allocator( ConstructAlloc & construct_alloc, ArgAlloc & arg_alloc, Pair* pair, piecewise_construct_t | |
335 | , Tuple<Args1...> t1, Tuple<Args2...> t2) | |
336 | { | |
337 | (dispatch_uses_allocator_index)( construct_alloc, arg_alloc, pair, t1, t2 | |
338 | , typename build_number_seq<sizeof...(Args1)>::type() | |
339 | , typename build_number_seq<sizeof...(Args2)>::type()); | |
340 | } | |
341 | ||
342 | #elif defined(BOOST_MSVC) && (_CPPLIB_VER == 520) | |
343 | ||
344 | //MSVC 2010 tuple implementation | |
345 | #define BOOST_DISPATCH_USES_ALLOCATOR_PIECEWISE_CONSTRUCT_MSVC2010_TUPLE_CODE(N,M)\ | |
346 | template< typename ConstructAlloc, typename ArgAlloc, class Pair\ | |
347 | , template<class, class, class, class, class, class, class, class, class, class> class StdTuple\ | |
348 | BOOST_MOVE_I_IF(BOOST_MOVE_OR(N,M)) BOOST_MOVE_CLASS##N BOOST_MOVE_I_IF(BOOST_MOVE_AND(N,M)) BOOST_MOVE_CLASSQ##M > \ | |
349 | typename container_detail::enable_if< container_detail::is_pair<Pair> >::type\ | |
350 | dispatch_uses_allocator(ConstructAlloc & construct_alloc, ArgAlloc & arg_alloc, Pair* pair, piecewise_construct_t\ | |
351 | , StdTuple<BOOST_MOVE_TARG##N BOOST_MOVE_I##N BOOST_MOVE_REPEAT(BOOST_MOVE_SUB(10,N),::std::tr1::_Nil)> p\ | |
352 | , StdTuple<BOOST_MOVE_TARGQ##M BOOST_MOVE_I##M BOOST_MOVE_REPEAT(BOOST_MOVE_SUB(10,M),::std::tr1::_Nil)> q)\ | |
353 | {\ | |
354 | (void)p; (void)q;\ | |
355 | (dispatch_uses_allocator)\ | |
356 | (construct_alloc, arg_alloc, container_detail::addressof(pair->first) BOOST_MOVE_I_IF(N) BOOST_MOVE_GET_IDX##N);\ | |
357 | BOOST_TRY{\ | |
358 | (dispatch_uses_allocator)\ | |
359 | (construct_alloc, arg_alloc, container_detail::addressof(pair->second) BOOST_MOVE_I_IF(M) BOOST_MOVE_GET_IDXQ##M);\ | |
360 | }\ | |
361 | BOOST_CATCH(...) {\ | |
362 | allocator_traits<ConstructAlloc>::destroy(construct_alloc, container_detail::addressof(pair->first));\ | |
363 | BOOST_RETHROW\ | |
364 | }\ | |
365 | BOOST_CATCH_END\ | |
366 | }\ | |
367 | // | |
368 | BOOST_MOVE_ITER2D_0TOMAX(9, BOOST_DISPATCH_USES_ALLOCATOR_PIECEWISE_CONSTRUCT_MSVC2010_TUPLE_CODE) | |
369 | #undef BOOST_DISPATCH_USES_ALLOCATOR_PIECEWISE_CONSTRUCT_MSVC2010_TUPLE_CODE | |
370 | ||
371 | #elif defined(BOOST_MSVC) && (_CPPLIB_VER == 540) | |
372 | #if _VARIADIC_MAX >= 9 | |
373 | #define BOOST_DISPATCH_USES_ALLOCATOR_PIECEWISE_CONSTRUCT_MSVC2012_TUPLE_MAX_IT 9 | |
374 | #else | |
375 | #define BOOST_DISPATCH_USES_ALLOCATOR_PIECEWISE_CONSTRUCT_MSVC2012_TUPLE_MAX_IT BOOST_MOVE_ADD(_VARIADIC_MAX, 1) | |
376 | #endif | |
377 | ||
378 | //MSVC 2012 tuple implementation | |
379 | #define BOOST_DISPATCH_USES_ALLOCATOR_PIECEWISE_CONSTRUCT_MSVC2012_TUPLE_CODE(N,M)\ | |
380 | template< typename ConstructAlloc, typename ArgAlloc, class Pair\ | |
381 | , template<BOOST_MOVE_REPEAT(_VARIADIC_MAX, class), class, class, class> class StdTuple \ | |
382 | BOOST_MOVE_I_IF(BOOST_MOVE_OR(N,M)) BOOST_MOVE_CLASS##N BOOST_MOVE_I_IF(BOOST_MOVE_AND(N,M)) BOOST_MOVE_CLASSQ##M > \ | |
383 | typename container_detail::enable_if< container_detail::is_pair<Pair> >::type\ | |
384 | dispatch_uses_allocator\ | |
385 | ( ConstructAlloc & construct_alloc, ArgAlloc & arg_alloc, Pair* pair, piecewise_construct_t\ | |
386 | , StdTuple<BOOST_MOVE_TARG##N BOOST_MOVE_I##N BOOST_MOVE_REPEAT(BOOST_MOVE_SUB(BOOST_MOVE_ADD(_VARIADIC_MAX, 3),N),::std::_Nil) > p\ | |
387 | , StdTuple<BOOST_MOVE_TARGQ##M BOOST_MOVE_I##M BOOST_MOVE_REPEAT(BOOST_MOVE_SUB(BOOST_MOVE_ADD(_VARIADIC_MAX, 3),M),::std::_Nil) > q)\ | |
388 | {\ | |
389 | (void)p; (void)q;\ | |
390 | (dispatch_uses_allocator)\ | |
391 | (construct_alloc, arg_alloc, container_detail::addressof(pair->first) BOOST_MOVE_I_IF(N) BOOST_MOVE_GET_IDX##N);\ | |
392 | BOOST_TRY{\ | |
393 | (dispatch_uses_allocator)\ | |
394 | (construct_alloc, arg_alloc, container_detail::addressof(pair->second) BOOST_MOVE_I_IF(M) BOOST_MOVE_GET_IDXQ##M);\ | |
395 | }\ | |
396 | BOOST_CATCH(...) {\ | |
397 | allocator_traits<ConstructAlloc>::destroy(construct_alloc, container_detail::addressof(pair->first));\ | |
398 | BOOST_RETHROW\ | |
399 | }\ | |
400 | BOOST_CATCH_END\ | |
401 | }\ | |
402 | // | |
403 | BOOST_MOVE_ITER2D_0TOMAX(BOOST_DISPATCH_USES_ALLOCATOR_PIECEWISE_CONSTRUCT_MSVC2012_TUPLE_MAX_IT, BOOST_DISPATCH_USES_ALLOCATOR_PIECEWISE_CONSTRUCT_MSVC2012_TUPLE_CODE) | |
404 | #undef BOOST_DISPATCH_USES_ALLOCATOR_PIECEWISE_CONSTRUCT_MSVC2010_TUPLE_CODE | |
405 | #undef BOOST_DISPATCH_USES_ALLOCATOR_PIECEWISE_CONSTRUCT_MSVC2012_TUPLE_MAX_IT | |
406 | ||
407 | #endif //!defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) | |
408 | ||
409 | } //namespace container_detail | |
410 | ||
411 | }} // namespace boost { namespace container { | |
412 | ||
413 | #include <boost/container/detail/config_end.hpp> | |
414 | ||
415 | #endif // BOOST_CONTAINER_DISPATCH_USES_ALLOCATOR_HPP |