1 //////////////////////////////////////////////////////////////////////////////
3 // (C) Copyright Ion Gaztanaga 2011-2013. 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)
7 // See http://www.boost.org/libs/container for documentation.
9 //////////////////////////////////////////////////////////////////////////////
10 #include <boost/container/detail/config_begin.hpp>
11 #include <boost/container/scoped_allocator_fwd.hpp>
14 #include <boost/container/detail/mpl.hpp>
16 #include <boost/move/utility_core.hpp>
17 #include <boost/move/adl_move_swap.hpp>
19 #include <boost/tuple/tuple.hpp>
24 #if defined(BOOST_CONTAINER_PAIR_TEST_HAS_HEADER_TUPLE)
29 #include <boost/core/lightweight_test.hpp>
31 #include "allocator_argument_tester.hpp"
33 template<unsigned int Type
>
37 struct mark_on_destructor
49 static bool destroyed
;
52 bool mark_on_destructor::destroyed
= false;
54 #include <boost/container/scoped_allocator.hpp>
55 #include <boost/static_assert.hpp>
56 #include <boost/container/vector.hpp>
57 #include <boost/container/detail/pair.hpp>
61 using namespace boost::container
;
63 typedef propagation_test_allocator
<tagged_integer
<0>, 0> OuterAlloc
;
64 typedef propagation_test_allocator
<tagged_integer
<0>, 10> Outer10IdAlloc
;
65 typedef propagation_test_allocator
<tagged_integer
<9>, 0> Rebound9OuterAlloc
;
66 typedef propagation_test_allocator
<tagged_integer
<1>, 1> InnerAlloc1
;
67 typedef propagation_test_allocator
<tagged_integer
<2>, 2> InnerAlloc2
;
68 typedef propagation_test_allocator
<tagged_integer
<1>, 11> Inner11IdAlloc1
;
70 typedef propagation_test_allocator
<tagged_integer
<0>, 0, false> OuterAllocFalseHasTrueTypes
;
71 typedef propagation_test_allocator
<tagged_integer
<0>, 0, true> OuterAllocTrueHasTrueTypes
;
72 typedef propagation_test_allocator
<tagged_integer
<1>, 1, false> InnerAlloc1FalseHasTrueTypes
;
73 typedef propagation_test_allocator
<tagged_integer
<1>, 1, true> InnerAlloc1TrueHasTrueTypes
;
74 typedef propagation_test_allocator
<tagged_integer
<2>, 2, false> InnerAlloc2FalseHasTrueTypes
;
75 typedef propagation_test_allocator
<tagged_integer
<2>, 2, true> InnerAlloc2TrueHasTrueTypes
;
78 typedef scoped_allocator_adaptor
< OuterAlloc
> Scoped0Inner
;
79 typedef scoped_allocator_adaptor
< OuterAlloc
80 , InnerAlloc1
> Scoped1Inner
;
81 typedef scoped_allocator_adaptor
< OuterAlloc
83 , InnerAlloc2
> Scoped2Inner
;
84 typedef scoped_allocator_adaptor
85 < scoped_allocator_adaptor
88 typedef scoped_allocator_adaptor
89 < scoped_allocator_adaptor
90 <Outer10IdAlloc
, Inner11IdAlloc1
>
93 typedef scoped_allocator_adaptor
< Rebound9OuterAlloc
> Rebound9Scoped0Inner
;
94 typedef scoped_allocator_adaptor
< Rebound9OuterAlloc
95 , InnerAlloc1
> Rebound9Scoped1Inner
;
96 typedef scoped_allocator_adaptor
< Rebound9OuterAlloc
98 , InnerAlloc2
> Rebound9Scoped2Inner
;
100 //outer_allocator_type
101 BOOST_STATIC_ASSERT(( container_detail::is_same
< OuterAlloc
102 , Scoped0Inner::outer_allocator_type
>::value
));
103 BOOST_STATIC_ASSERT(( container_detail::is_same
< OuterAlloc
104 , Scoped1Inner::outer_allocator_type
>::value
));
105 BOOST_STATIC_ASSERT(( container_detail::is_same
< OuterAlloc
106 , Scoped2Inner::outer_allocator_type
>::value
));
108 BOOST_STATIC_ASSERT(( container_detail::is_same
< allocator_traits
<OuterAlloc
>::value_type
109 , Scoped0Inner::value_type
>::value
));
110 BOOST_STATIC_ASSERT(( container_detail::is_same
< allocator_traits
<OuterAlloc
>::value_type
111 , Scoped1Inner::value_type
>::value
));
112 BOOST_STATIC_ASSERT(( container_detail::is_same
< allocator_traits
<OuterAlloc
>::value_type
113 , Scoped2Inner::value_type
>::value
));
115 BOOST_STATIC_ASSERT(( container_detail::is_same
< allocator_traits
<OuterAlloc
>::size_type
116 , Scoped0Inner::size_type
>::value
));
117 BOOST_STATIC_ASSERT(( container_detail::is_same
< allocator_traits
<OuterAlloc
>::size_type
118 , Scoped1Inner::size_type
>::value
));
119 BOOST_STATIC_ASSERT(( container_detail::is_same
< allocator_traits
<OuterAlloc
>::size_type
120 , Scoped2Inner::size_type
>::value
));
123 BOOST_STATIC_ASSERT(( container_detail::is_same
< allocator_traits
<OuterAlloc
>::difference_type
124 , Scoped0Inner::difference_type
>::value
));
125 BOOST_STATIC_ASSERT(( container_detail::is_same
< allocator_traits
<OuterAlloc
>::difference_type
126 , Scoped1Inner::difference_type
>::value
));
127 BOOST_STATIC_ASSERT(( container_detail::is_same
< allocator_traits
<OuterAlloc
>::difference_type
128 , Scoped2Inner::difference_type
>::value
));
131 BOOST_STATIC_ASSERT(( container_detail::is_same
< allocator_traits
<OuterAlloc
>::pointer
132 , Scoped0Inner::pointer
>::value
));
133 BOOST_STATIC_ASSERT(( container_detail::is_same
< allocator_traits
<OuterAlloc
>::pointer
134 , Scoped1Inner::pointer
>::value
));
135 BOOST_STATIC_ASSERT(( container_detail::is_same
< allocator_traits
<OuterAlloc
>::pointer
136 , Scoped2Inner::pointer
>::value
));
139 BOOST_STATIC_ASSERT(( container_detail::is_same
< allocator_traits
<OuterAlloc
>::const_pointer
140 , Scoped0Inner::const_pointer
>::value
));
141 BOOST_STATIC_ASSERT(( container_detail::is_same
< allocator_traits
<OuterAlloc
>::const_pointer
142 , Scoped1Inner::const_pointer
>::value
));
143 BOOST_STATIC_ASSERT(( container_detail::is_same
< allocator_traits
<OuterAlloc
>::const_pointer
144 , Scoped2Inner::const_pointer
>::value
));
147 BOOST_STATIC_ASSERT(( container_detail::is_same
< allocator_traits
<OuterAlloc
>::void_pointer
148 , Scoped0Inner::void_pointer
>::value
));
149 BOOST_STATIC_ASSERT(( container_detail::is_same
< allocator_traits
<OuterAlloc
>::void_pointer
150 , Scoped1Inner::void_pointer
>::value
));
151 BOOST_STATIC_ASSERT(( container_detail::is_same
< allocator_traits
<OuterAlloc
>::void_pointer
152 , Scoped2Inner::void_pointer
>::value
));
155 BOOST_STATIC_ASSERT(( container_detail::is_same
< allocator_traits
<OuterAlloc
>::const_void_pointer
156 , Scoped0Inner::const_void_pointer
>::value
));
157 BOOST_STATIC_ASSERT(( container_detail::is_same
< allocator_traits
<OuterAlloc
>::const_void_pointer
158 , Scoped1Inner::const_void_pointer
>::value
));
159 BOOST_STATIC_ASSERT(( container_detail::is_same
< allocator_traits
<OuterAlloc
>::const_void_pointer
160 , Scoped2Inner::const_void_pointer
>::value
));
163 BOOST_STATIC_ASSERT(( container_detail::is_same
<Scoped0Inner::rebind
< tagged_integer
<9> >::other
164 , Rebound9Scoped0Inner
>::value
));
165 BOOST_STATIC_ASSERT(( container_detail::is_same
<Scoped1Inner::rebind
< tagged_integer
<9> >::other
166 , Rebound9Scoped1Inner
>::value
));
167 BOOST_STATIC_ASSERT(( container_detail::is_same
<Scoped2Inner::rebind
< tagged_integer
<9> >::other
168 , Rebound9Scoped2Inner
>::value
));
170 //inner_allocator_type
171 BOOST_STATIC_ASSERT(( container_detail::is_same
< Scoped0Inner
172 , Scoped0Inner::inner_allocator_type
>::value
));
173 BOOST_STATIC_ASSERT(( container_detail::is_same
< scoped_allocator_adaptor
<InnerAlloc1
>
174 , Scoped1Inner::inner_allocator_type
>::value
));
175 BOOST_STATIC_ASSERT(( container_detail::is_same
< scoped_allocator_adaptor
<InnerAlloc1
, InnerAlloc2
>
176 , Scoped2Inner::inner_allocator_type
>::value
));
180 typedef scoped_allocator_adaptor
< OuterAllocFalseHasTrueTypes
> Scoped0InnerF
;
181 typedef scoped_allocator_adaptor
< OuterAllocTrueHasTrueTypes
> Scoped0InnerT
;
182 typedef scoped_allocator_adaptor
< OuterAllocFalseHasTrueTypes
183 , InnerAlloc1FalseHasTrueTypes
> Scoped1InnerFF
;
184 typedef scoped_allocator_adaptor
< OuterAllocFalseHasTrueTypes
185 , InnerAlloc1TrueHasTrueTypes
> Scoped1InnerFT
;
186 typedef scoped_allocator_adaptor
< OuterAllocTrueHasTrueTypes
187 , InnerAlloc1FalseHasTrueTypes
> Scoped1InnerTF
;
188 typedef scoped_allocator_adaptor
< OuterAllocTrueHasTrueTypes
189 , InnerAlloc1TrueHasTrueTypes
> Scoped1InnerTT
;
190 typedef scoped_allocator_adaptor
< OuterAllocFalseHasTrueTypes
191 , InnerAlloc1FalseHasTrueTypes
192 , InnerAlloc2FalseHasTrueTypes
> Scoped2InnerFFF
;
193 typedef scoped_allocator_adaptor
< OuterAllocFalseHasTrueTypes
194 , InnerAlloc1FalseHasTrueTypes
195 , InnerAlloc2TrueHasTrueTypes
> Scoped2InnerFFT
;
196 typedef scoped_allocator_adaptor
< OuterAllocFalseHasTrueTypes
197 , InnerAlloc1TrueHasTrueTypes
198 , InnerAlloc2FalseHasTrueTypes
> Scoped2InnerFTF
;
199 typedef scoped_allocator_adaptor
< OuterAllocFalseHasTrueTypes
200 , InnerAlloc1TrueHasTrueTypes
201 , InnerAlloc2TrueHasTrueTypes
> Scoped2InnerFTT
;
202 typedef scoped_allocator_adaptor
< OuterAllocTrueHasTrueTypes
203 , InnerAlloc1FalseHasTrueTypes
204 , InnerAlloc2FalseHasTrueTypes
> Scoped2InnerTFF
;
205 typedef scoped_allocator_adaptor
< OuterAllocTrueHasTrueTypes
206 , InnerAlloc1FalseHasTrueTypes
207 , InnerAlloc2TrueHasTrueTypes
> Scoped2InnerTFT
;
208 typedef scoped_allocator_adaptor
< OuterAllocTrueHasTrueTypes
209 , InnerAlloc1TrueHasTrueTypes
210 , InnerAlloc2FalseHasTrueTypes
> Scoped2InnerTTF
;
211 typedef scoped_allocator_adaptor
< OuterAllocTrueHasTrueTypes
212 , InnerAlloc1TrueHasTrueTypes
213 , InnerAlloc2TrueHasTrueTypes
> Scoped2InnerTTT
;
215 //propagate_on_container_copy_assignment
217 BOOST_STATIC_ASSERT(( !Scoped0InnerF::propagate_on_container_copy_assignment::value
));
218 BOOST_STATIC_ASSERT(( Scoped0InnerT::propagate_on_container_copy_assignment::value
));
220 BOOST_STATIC_ASSERT(( !Scoped1InnerFF::propagate_on_container_copy_assignment::value
));
221 BOOST_STATIC_ASSERT(( Scoped1InnerFT::propagate_on_container_copy_assignment::value
));
222 BOOST_STATIC_ASSERT(( Scoped1InnerTF::propagate_on_container_copy_assignment::value
));
223 BOOST_STATIC_ASSERT(( Scoped1InnerTT::propagate_on_container_copy_assignment::value
));
225 BOOST_STATIC_ASSERT(( !Scoped2InnerFFF::propagate_on_container_copy_assignment::value
));
226 BOOST_STATIC_ASSERT(( Scoped2InnerFFT::propagate_on_container_copy_assignment::value
));
227 BOOST_STATIC_ASSERT(( Scoped2InnerFTF::propagate_on_container_copy_assignment::value
));
228 BOOST_STATIC_ASSERT(( Scoped2InnerFTT::propagate_on_container_copy_assignment::value
));
229 BOOST_STATIC_ASSERT(( Scoped2InnerTFF::propagate_on_container_copy_assignment::value
));
230 BOOST_STATIC_ASSERT(( Scoped2InnerTFT::propagate_on_container_copy_assignment::value
));
231 BOOST_STATIC_ASSERT(( Scoped2InnerTTF::propagate_on_container_copy_assignment::value
));
232 BOOST_STATIC_ASSERT(( Scoped2InnerTTT::propagate_on_container_copy_assignment::value
));
234 //propagate_on_container_move_assignment
236 BOOST_STATIC_ASSERT(( !Scoped0InnerF::propagate_on_container_move_assignment::value
));
237 BOOST_STATIC_ASSERT(( Scoped0InnerT::propagate_on_container_move_assignment::value
));
239 BOOST_STATIC_ASSERT(( !Scoped1InnerFF::propagate_on_container_move_assignment::value
));
240 BOOST_STATIC_ASSERT(( Scoped1InnerFT::propagate_on_container_move_assignment::value
));
241 BOOST_STATIC_ASSERT(( Scoped1InnerTF::propagate_on_container_move_assignment::value
));
242 BOOST_STATIC_ASSERT(( Scoped1InnerTT::propagate_on_container_move_assignment::value
));
244 BOOST_STATIC_ASSERT(( !Scoped2InnerFFF::propagate_on_container_move_assignment::value
));
245 BOOST_STATIC_ASSERT(( Scoped2InnerFFT::propagate_on_container_move_assignment::value
));
246 BOOST_STATIC_ASSERT(( Scoped2InnerFTF::propagate_on_container_move_assignment::value
));
247 BOOST_STATIC_ASSERT(( Scoped2InnerFTT::propagate_on_container_move_assignment::value
));
248 BOOST_STATIC_ASSERT(( Scoped2InnerTFF::propagate_on_container_move_assignment::value
));
249 BOOST_STATIC_ASSERT(( Scoped2InnerTFT::propagate_on_container_move_assignment::value
));
250 BOOST_STATIC_ASSERT(( Scoped2InnerTTF::propagate_on_container_move_assignment::value
));
251 BOOST_STATIC_ASSERT(( Scoped2InnerTTT::propagate_on_container_move_assignment::value
));
253 //propagate_on_container_swap
255 BOOST_STATIC_ASSERT(( !Scoped0InnerF::propagate_on_container_swap::value
));
256 BOOST_STATIC_ASSERT(( Scoped0InnerT::propagate_on_container_swap::value
));
258 BOOST_STATIC_ASSERT(( !Scoped1InnerFF::propagate_on_container_swap::value
));
259 BOOST_STATIC_ASSERT(( Scoped1InnerFT::propagate_on_container_swap::value
));
260 BOOST_STATIC_ASSERT(( Scoped1InnerTF::propagate_on_container_swap::value
));
261 BOOST_STATIC_ASSERT(( Scoped1InnerTT::propagate_on_container_swap::value
));
263 BOOST_STATIC_ASSERT(( !Scoped2InnerFFF::propagate_on_container_swap::value
));
264 BOOST_STATIC_ASSERT(( Scoped2InnerFFT::propagate_on_container_swap::value
));
265 BOOST_STATIC_ASSERT(( Scoped2InnerFTF::propagate_on_container_swap::value
));
266 BOOST_STATIC_ASSERT(( Scoped2InnerFTT::propagate_on_container_swap::value
));
267 BOOST_STATIC_ASSERT(( Scoped2InnerTFF::propagate_on_container_swap::value
));
268 BOOST_STATIC_ASSERT(( Scoped2InnerTFT::propagate_on_container_swap::value
));
269 BOOST_STATIC_ASSERT(( Scoped2InnerTTF::propagate_on_container_swap::value
));
270 BOOST_STATIC_ASSERT(( Scoped2InnerTTT::propagate_on_container_swap::value
));
273 BOOST_STATIC_ASSERT(( !Scoped0InnerF::is_always_equal::value
));
274 BOOST_STATIC_ASSERT(( Scoped0InnerT::is_always_equal::value
));
276 BOOST_STATIC_ASSERT(( !Scoped1InnerFF::is_always_equal::value
));
277 BOOST_STATIC_ASSERT(( !Scoped1InnerFT::is_always_equal::value
));
278 BOOST_STATIC_ASSERT(( !Scoped1InnerTF::is_always_equal::value
));
279 BOOST_STATIC_ASSERT(( Scoped1InnerTT::is_always_equal::value
));
281 BOOST_STATIC_ASSERT(( !Scoped2InnerFFF::is_always_equal::value
));
282 BOOST_STATIC_ASSERT(( !Scoped2InnerFFT::is_always_equal::value
));
283 BOOST_STATIC_ASSERT(( !Scoped2InnerFTF::is_always_equal::value
));
284 BOOST_STATIC_ASSERT(( !Scoped2InnerFTT::is_always_equal::value
));
285 BOOST_STATIC_ASSERT(( !Scoped2InnerTFF::is_always_equal::value
));
286 BOOST_STATIC_ASSERT(( !Scoped2InnerTFT::is_always_equal::value
));
287 BOOST_STATIC_ASSERT(( !Scoped2InnerTTF::is_always_equal::value
));
288 BOOST_STATIC_ASSERT(( Scoped2InnerTTT::is_always_equal::value
));
291 //Default constructor
299 boost::adl_move_swap(s0i
, s0i2
);
300 boost::adl_move_swap(s1i
, s1i2
);
304 //Default constructor
310 //Copy constructor/assignment
316 Scoped0Inner
s0i_b(s0i
);
317 Scoped1Inner
s1i_b(s1i
);
318 Scoped2Inner
s2i_b(s2i
);
320 BOOST_TEST(s0i
== s0i_b
);
321 BOOST_TEST(s1i
== s1i_b
);
322 BOOST_TEST(s2i
== s2i_b
);
328 BOOST_TEST(s0i
== s0i_b
);
329 BOOST_TEST(s1i
== s1i_b
);
330 BOOST_TEST(s2i
== s2i_b
);
333 //Copy/move constructor/assignment
339 Scoped0Inner
s0i_b(::boost::move(s0i
));
340 Scoped1Inner
s1i_b(::boost::move(s1i
));
341 Scoped2Inner
s2i_b(::boost::move(s2i
));
343 BOOST_TEST(s0i_b
.outer_allocator().m_move_contructed
);
344 BOOST_TEST(s1i_b
.outer_allocator().m_move_contructed
);
345 BOOST_TEST(s2i_b
.outer_allocator().m_move_contructed
);
347 s0i_b
= ::boost::move(s0i
);
348 s1i_b
= ::boost::move(s1i
);
349 s2i_b
= ::boost::move(s2i
);
351 BOOST_TEST(s0i_b
.outer_allocator().m_move_assigned
);
352 BOOST_TEST(s1i_b
.outer_allocator().m_move_assigned
);
353 BOOST_TEST(s2i_b
.outer_allocator().m_move_assigned
);
361 const Scoped0Inner const_s0i
;
362 const Scoped1Inner const_s1i
;
363 const Scoped2Inner const_s2i
;
365 Scoped0Inner::inner_allocator_type
&s0i_inner
= s0i
.inner_allocator();
367 const Scoped0Inner::inner_allocator_type
&const_s0i_inner
= const_s0i
.inner_allocator();
368 (void)const_s0i_inner
;
369 Scoped1Inner::inner_allocator_type
&s1i_inner
= s1i
.inner_allocator();
371 const Scoped1Inner::inner_allocator_type
&const_s1i_inner
= const_s1i
.inner_allocator();
372 (void)const_s1i_inner
;
373 Scoped2Inner::inner_allocator_type
&s2i_inner
= s2i
.inner_allocator();
375 const Scoped2Inner::inner_allocator_type
&const_s2i_inner
= const_s2i
.inner_allocator();
376 (void)const_s2i_inner
;
381 const Scoped0Inner const_s0i
;
382 const Rebound9Scoped0Inner const_rs0i
;
384 BOOST_TEST(const_s0i
== const_s0i
);
385 BOOST_TEST(const_rs0i
== const_s0i
);
386 BOOST_TEST(const_s0i
== const_s0i
);
387 BOOST_TEST(const_s0i
== const_rs0i
);
389 const Scoped1Inner const_s1i
;
390 const Rebound9Scoped1Inner const_rs1i
;
392 BOOST_TEST(const_s1i
== const_s1i
);
393 BOOST_TEST(const_rs1i
== const_s1i
);
395 BOOST_TEST(const_s1i
== const_s1i
);
396 BOOST_TEST(const_s1i
== const_rs1i
);
398 const Scoped2Inner const_s2i
;
399 const Rebound9Scoped2Inner const_rs2i
;
401 BOOST_TEST(const_s2i
== const_s2i
);
402 BOOST_TEST(const_s2i
== const_rs2i
);
404 BOOST_TEST(const_s2i
== const_s2i
);
405 BOOST_TEST(const_s2i
== const_rs2i
);
413 const Scoped0Inner const_s0i
;
414 const Scoped1Inner const_s1i
;
415 const Scoped2Inner const_s2i
;
417 Scoped0Inner::outer_allocator_type
&s0i_inner
= s0i
.outer_allocator();
419 const Scoped0Inner::outer_allocator_type
&const_s0i_inner
= const_s0i
.outer_allocator();
420 (void)const_s0i_inner
;
421 Scoped1Inner::outer_allocator_type
&s1i_inner
= s1i
.outer_allocator();
423 const Scoped1Inner::outer_allocator_type
&const_s1i_inner
= const_s1i
.outer_allocator();
424 (void)const_s1i_inner
;
425 Scoped2Inner::outer_allocator_type
&s2i_inner
= s2i
.outer_allocator();
427 const Scoped2Inner::outer_allocator_type
&const_s2i_inner
= const_s2i
.outer_allocator();
428 (void)const_s2i_inner
;
433 const Scoped0Inner const_s0i
;
434 const Scoped1Inner const_s1i
;
435 const Scoped2Inner const_s2i
;
436 const OuterAlloc const_oa
;
437 const InnerAlloc1 const_ia1
;
438 const InnerAlloc2 const_ia2
;
440 BOOST_TEST(const_s0i
.max_size() == const_oa
.max_size());
441 BOOST_TEST(const_s1i
.max_size() == const_oa
.max_size());
443 BOOST_TEST(const_s2i
.max_size() == const_oa
.max_size());
444 BOOST_TEST(const_s1i
.inner_allocator().max_size() == const_ia1
.max_size());
445 BOOST_TEST(const_s2i
.inner_allocator().inner_allocator().max_size() == const_ia2
.max_size());
447 //Copy and move operations
451 Scoped0Inner s0i_a
, s0i_b(s0i_a
), s0i_c(::boost::move(s0i_b
));
452 Scoped1Inner s1i_a
, s1i_b(s1i_a
), s1i_c(::boost::move(s1i_b
));
453 Scoped2Inner s2i_a
, s2i_b(s2i_a
), s2i_c(::boost::move(s2i_b
));
457 Scoped0Inner s0i_a
, s0i_b
;
459 s0i_a
= ::boost::move(s0i_b
);
460 Scoped1Inner s1i_a
, s1i_b
;
462 s1i_a
= ::boost::move(s1i_b
);
463 Scoped2Inner s2i_a
, s2i_b
;
465 s2i_a
= ::boost::move(s2i_b
);
471 Rebound9OuterAlloc roa
;
472 Rebound9Scoped0Inner rs0i
;
473 Rebound9Scoped1Inner rs1i
;
474 Rebound9Scoped2Inner rs2i
;
478 Scoped0Inner
s0i(oa
);
479 Scoped1Inner
s1i(oa
, ia1
);
480 Scoped2Inner
s2i(oa
, ia1
, ia2
);
484 Scoped0Inner
s0i(::boost::move(oa
));
485 Scoped1Inner
s1i(::boost::move(oa
), ia1
);
486 Scoped2Inner
s2i(::boost::move(oa
), ia1
, ia2
);
488 //Copy from rebound outer
490 Scoped0Inner
s0i(roa
);
491 Scoped1Inner
s1i(roa
, ia1
);
492 Scoped2Inner
s2i(roa
, ia1
, ia2
);
494 //Move from rebound outer
496 Scoped0Inner
s0i(::boost::move(roa
));
497 Scoped1Inner
s1i(::boost::move(roa
), ia1
);
498 Scoped2Inner
s2i(::boost::move(roa
), ia1
, ia2
);
500 //Copy from rebound scoped
502 Scoped0Inner
s0i(rs0i
);
503 Scoped1Inner
s1i(rs1i
);
504 Scoped2Inner
s2i(rs2i
);
506 //Move from rebound scoped
508 Scoped0Inner
s0i(::boost::move(rs0i
));
509 Scoped1Inner
s1i(::boost::move(rs1i
));
510 Scoped2Inner
s2i(::boost::move(rs2i
));
515 vector
<int, scoped_allocator_adaptor
< propagation_test_allocator
<int, 0> > > dummy
;
523 mark_on_destructor mod
;
525 BOOST_TEST(mark_on_destructor::destroyed
);
530 mark_on_destructor mod
;
532 BOOST_TEST(mark_on_destructor::destroyed
);
536 mark_on_destructor mod
;
538 BOOST_TEST(mark_on_destructor::destroyed
);
544 ////////////////////////////////////////////////////////////
545 //First check scoped allocator with just OuterAlloc.
546 //In this case OuterAlloc (propagation_test_allocator with tag 0) should be
547 //used to construct types.
548 ////////////////////////////////////////////////////////////
551 //Check construction with 0 user arguments
553 typedef ::allocator_argument_tester
<NotUsesAllocator
, 0> MarkType
;
556 s0i
.construct(&dummy
);
557 BOOST_TEST(dummy
.construction_type
== NotUsesAllocator
);
558 BOOST_TEST(dummy
.value
== 0 );
562 typedef ::allocator_argument_tester
<ConstructibleSuffix
, 0> MarkType
;
565 s0i
.construct(&dummy
);
566 BOOST_TEST(dummy
.construction_type
== ConstructibleSuffix
);
567 BOOST_TEST(dummy
.value
== 0);
571 typedef ::allocator_argument_tester
<ConstructiblePrefix
, 0> MarkType
;
574 s0i
.construct(&dummy
);
575 BOOST_TEST(dummy
.construction_type
== ConstructiblePrefix
);
576 BOOST_TEST(dummy
.value
== 0);
580 //Check construction with 1 user arguments
582 typedef ::allocator_argument_tester
<NotUsesAllocator
, 0> MarkType
;
585 s0i
.construct(&dummy
, 1);
586 BOOST_TEST(dummy
.construction_type
== NotUsesAllocator
);
587 BOOST_TEST(dummy
.value
== 1);
591 typedef ::allocator_argument_tester
<ConstructibleSuffix
, 0> MarkType
;
594 s0i
.construct(&dummy
, 2);
595 BOOST_TEST(dummy
.construction_type
== ConstructibleSuffix
);
596 BOOST_TEST(dummy
.value
== 2);
600 typedef ::allocator_argument_tester
<ConstructiblePrefix
, 0> MarkType
;
603 s0i
.construct(&dummy
, 3);
604 BOOST_TEST(dummy
.construction_type
== ConstructiblePrefix
);
605 BOOST_TEST(dummy
.value
== 3);
609 ////////////////////////////////////////////////////////////
610 //Then check scoped allocator with OuterAlloc and InnerAlloc.
611 //In this case InnerAlloc (propagation_test_allocator with tag 1) should be
612 //used to construct types.
613 ////////////////////////////////////////////////////////////
616 //Check construction with 0 user arguments
618 typedef ::allocator_argument_tester
<NotUsesAllocator
, 1> MarkType
;
621 s1i
.construct(&dummy
);
622 BOOST_TEST(dummy
.construction_type
== NotUsesAllocator
);
623 BOOST_TEST(dummy
.value
== 0);
627 typedef ::allocator_argument_tester
<ConstructibleSuffix
, 1> MarkType
;
630 s1i
.construct(&dummy
);
631 BOOST_TEST(dummy
.construction_type
== ConstructibleSuffix
);
632 BOOST_TEST(dummy
.value
== 0);
636 typedef ::allocator_argument_tester
<ConstructiblePrefix
, 1> MarkType
;
639 s1i
.construct(&dummy
);
640 BOOST_TEST(dummy
.construction_type
== ConstructiblePrefix
);
641 BOOST_TEST(dummy
.value
== 0);
645 //Check construction with 1 user arguments
647 typedef ::allocator_argument_tester
<NotUsesAllocator
, 1> MarkType
;
650 s1i
.construct(&dummy
, 1);
651 BOOST_TEST(dummy
.construction_type
== NotUsesAllocator
);
652 BOOST_TEST(dummy
.value
== 1);
656 typedef ::allocator_argument_tester
<ConstructibleSuffix
, 1> MarkType
;
659 s1i
.construct(&dummy
, 2);
660 BOOST_TEST(dummy
.construction_type
== ConstructibleSuffix
);
661 BOOST_TEST(dummy
.value
== 2);
665 typedef ::allocator_argument_tester
<ConstructiblePrefix
, 1> MarkType
;
668 s1i
.construct(&dummy
, 3);
669 BOOST_TEST(dummy
.construction_type
== ConstructiblePrefix
);
670 BOOST_TEST(dummy
.value
== 3);
675 //////////////////////////////////////////////////////////////////////////////////
676 //Now test recursive OuterAllocator types (OuterAllocator is a scoped_allocator)
677 //////////////////////////////////////////////////////////////////////////////////
679 ////////////////////////////////////////////////////////////
680 //First check scoped allocator with just OuterAlloc.
681 //In this case OuterAlloc (propagation_test_allocator with tag 0) should be
682 //used to construct types.
683 ////////////////////////////////////////////////////////////
685 //Check outer_allocator_type is scoped
686 BOOST_STATIC_ASSERT(( is_scoped_allocator
687 <ScopedScoped0Inner::outer_allocator_type
>::value
));
688 BOOST_STATIC_ASSERT(( container_detail::is_same
689 < outermost_allocator
<ScopedScoped0Inner
>::type
692 BOOST_STATIC_ASSERT(( container_detail::is_same
693 < ScopedScoped0Inner::outer_allocator_type
694 , scoped_allocator_adaptor
<Outer10IdAlloc
>
696 BOOST_STATIC_ASSERT(( container_detail::is_same
697 < scoped_allocator_adaptor
<Outer10IdAlloc
>::outer_allocator_type
700 ScopedScoped0Inner ssro0i
;
701 Outer10IdAlloc
& val
= outermost_allocator
<ScopedScoped0Inner
>::get(ssro0i
);
703 //Check construction with 0 user arguments
705 typedef ::allocator_argument_tester
<NotUsesAllocator
, 10> MarkType
;
708 ssro0i
.construct(&dummy
);
709 BOOST_TEST(dummy
.construction_type
== NotUsesAllocator
);
710 BOOST_TEST(dummy
.value
== 0);
714 typedef ::allocator_argument_tester
<ConstructibleSuffix
, 10> MarkType
;
717 ssro0i
.construct(&dummy
);
718 BOOST_TEST(dummy
.construction_type
== ConstructibleSuffix
);
719 BOOST_TEST(dummy
.value
== 0);
723 typedef ::allocator_argument_tester
<ConstructiblePrefix
, 10> MarkType
;
726 ssro0i
.construct(&dummy
);
727 BOOST_TEST(dummy
.construction_type
== ConstructiblePrefix
);
728 BOOST_TEST(dummy
.value
== 0);
732 //Check construction with 1 user arguments
734 typedef ::allocator_argument_tester
<NotUsesAllocator
, 10> MarkType
;
737 ssro0i
.construct(&dummy
, 1);
738 BOOST_TEST(dummy
.construction_type
== NotUsesAllocator
);
739 BOOST_TEST(dummy
.value
== 1);
743 typedef ::allocator_argument_tester
<ConstructibleSuffix
, 10> MarkType
;
746 ssro0i
.construct(&dummy
, 2);
747 BOOST_TEST(dummy
.construction_type
== ConstructibleSuffix
);
748 BOOST_TEST(dummy
.value
== 2);
752 typedef ::allocator_argument_tester
<ConstructiblePrefix
, 10> MarkType
;
755 ssro0i
.construct(&dummy
, 3);
756 BOOST_TEST(dummy
.construction_type
== ConstructiblePrefix
);
757 BOOST_TEST(dummy
.value
== 3);
761 ////////////////////////////////////////////////////////////
762 //Then check scoped allocator with OuterAlloc and InnerAlloc.
763 //In this case inner_allocator_type is not convertible to
764 //::allocator_argument_tester<XXX, 10> so uses_allocator
765 //should be false on all tests.
766 ////////////////////////////////////////////////////////////
768 //Check outer_allocator_type is scoped
769 BOOST_STATIC_ASSERT(( is_scoped_allocator
770 <ScopedScoped1Inner::outer_allocator_type
>::value
));
771 BOOST_STATIC_ASSERT(( container_detail::is_same
772 < outermost_allocator
<ScopedScoped1Inner
>::type
775 BOOST_STATIC_ASSERT(( container_detail::is_same
776 < ScopedScoped1Inner::outer_allocator_type
777 , scoped_allocator_adaptor
<Outer10IdAlloc
, Inner11IdAlloc1
>
779 BOOST_STATIC_ASSERT(( container_detail::is_same
780 < scoped_allocator_adaptor
<Outer10IdAlloc
, Inner11IdAlloc1
>::outer_allocator_type
783 BOOST_STATIC_ASSERT(( !
785 < ::allocator_argument_tester
<ConstructibleSuffix
, 10>
786 , ScopedScoped1Inner::inner_allocator_type::outer_allocator_type
788 ScopedScoped1Inner ssro1i
;
789 Outer10IdAlloc
& val
= outermost_allocator
<ScopedScoped1Inner
>::get(ssro1i
);
792 //Check construction with 0 user arguments
794 typedef ::allocator_argument_tester
<NotUsesAllocator
, 10> MarkType
;
797 ssro1i
.construct(&dummy
);
798 BOOST_TEST(dummy
.construction_type
== NotUsesAllocator
);
799 BOOST_TEST(dummy
.value
== 0);
803 typedef ::allocator_argument_tester
<ConstructibleSuffix
, 10> MarkType
;
806 ssro1i
.construct(&dummy
);
807 BOOST_TEST(dummy
.construction_type
== NotUsesAllocator
);
808 BOOST_TEST(dummy
.value
== 0);
812 typedef ::allocator_argument_tester
<ConstructiblePrefix
, 10> MarkType
;
815 ssro1i
.construct(&dummy
);
816 BOOST_TEST(dummy
.construction_type
== NotUsesAllocator
);
817 BOOST_TEST(dummy
.value
== 0);
821 //Check construction with 1 user arguments
823 typedef ::allocator_argument_tester
<NotUsesAllocator
, 10> MarkType
;
826 ssro1i
.construct(&dummy
, 1);
827 BOOST_TEST(dummy
.construction_type
== NotUsesAllocator
);
828 BOOST_TEST(dummy
.value
== 1);
832 typedef ::allocator_argument_tester
<ConstructibleSuffix
, 10> MarkType
;
835 ssro1i
.construct(&dummy
, 2);
836 BOOST_TEST(dummy
.construction_type
== NotUsesAllocator
);
837 BOOST_TEST(dummy
.value
== 2);
841 typedef ::allocator_argument_tester
<ConstructiblePrefix
, 10> MarkType
;
844 ssro1i
.construct(&dummy
, 3);
845 BOOST_TEST(dummy
.construction_type
== NotUsesAllocator
);
846 BOOST_TEST(dummy
.value
== 3);
851 ////////////////////////////////////////////////////////////
852 //Now check propagation to pair
853 ////////////////////////////////////////////////////////////
854 //First check scoped allocator with just OuterAlloc.
855 //In this case OuterAlloc (propagation_test_allocator with tag 0) should be
856 //used to construct types.
857 ////////////////////////////////////////////////////////////
859 using container_detail::pair
;
860 typedef propagation_test_allocator
< pair
< tagged_integer
<0>
861 , tagged_integer
<0> >, 0> OuterPairAlloc
;
863 typedef scoped_allocator_adaptor
< OuterPairAlloc
> ScopedPair0Inner
;
865 ScopedPair0Inner s0i
;
866 //Check construction with 0 user arguments
868 typedef ::allocator_argument_tester
<NotUsesAllocator
, 0> MarkType
;
869 typedef pair
<MarkType
, MarkType
> MarkTypePair
;
871 dummy
.~MarkTypePair();
872 s0i
.construct(&dummy
);
873 BOOST_TEST(dummy
.first
.construction_type
== NotUsesAllocator
);
874 BOOST_TEST(dummy
.second
.construction_type
== NotUsesAllocator
);
875 BOOST_TEST(dummy
.first
.value
== 0);
876 BOOST_TEST(dummy
.second
.value
== 0);
877 dummy
.~MarkTypePair();
880 typedef ::allocator_argument_tester
<ConstructibleSuffix
, 0> MarkType
;
881 typedef pair
<MarkType
, MarkType
> MarkTypePair
;
883 dummy
.~MarkTypePair();
884 s0i
.construct(&dummy
);
885 BOOST_TEST(dummy
.first
.construction_type
== ConstructibleSuffix
);
886 BOOST_TEST(dummy
.second
.construction_type
== ConstructibleSuffix
);
887 BOOST_TEST(dummy
.first
.value
== 0);
888 BOOST_TEST(dummy
.second
.value
== 0);
889 dummy
.~MarkTypePair();
892 typedef ::allocator_argument_tester
<ConstructiblePrefix
, 0> MarkType
;
893 typedef pair
<MarkType
, MarkType
> MarkTypePair
;
895 dummy
.~MarkTypePair();
896 s0i
.construct(&dummy
);
897 BOOST_TEST(dummy
.first
.construction_type
== ConstructiblePrefix
);
898 BOOST_TEST(dummy
.second
.construction_type
== ConstructiblePrefix
);
899 BOOST_TEST(dummy
.first
.value
== 0);
900 BOOST_TEST(dummy
.second
.value
== 0);
901 dummy
.~MarkTypePair();
903 #if defined(BOOST_CONTAINER_PAIR_TEST_HAS_HEADER_TUPLE)
904 //Check construction with 0 user arguments and Std tuple
906 typedef ::allocator_argument_tester
<NotUsesAllocator
, 0> MarkType
;
907 typedef pair
<MarkType
, MarkType
> MarkTypePair
;
909 dummy
.~MarkTypePair();
910 s0i
.construct(&dummy
, piecewise_construct
, std::tuple
<>(), std::tuple
<>());
911 BOOST_TEST(dummy
.first
.construction_type
== NotUsesAllocator
);
912 BOOST_TEST(dummy
.second
.construction_type
== NotUsesAllocator
);
913 BOOST_TEST(dummy
.first
.value
== 0);
914 BOOST_TEST(dummy
.second
.value
== 0);
915 dummy
.~MarkTypePair();
918 typedef ::allocator_argument_tester
<ConstructibleSuffix
, 0> MarkType
;
919 typedef pair
<MarkType
, MarkType
> MarkTypePair
;
921 dummy
.~MarkTypePair();
922 s0i
.construct(&dummy
, piecewise_construct
, std::tuple
<>(), std::tuple
<>());
923 BOOST_TEST(dummy
.first
.construction_type
== ConstructibleSuffix
);
924 BOOST_TEST(dummy
.second
.construction_type
== ConstructibleSuffix
);
925 BOOST_TEST(dummy
.first
.value
== 0);
926 BOOST_TEST(dummy
.second
.value
== 0);
927 dummy
.~MarkTypePair();
930 typedef ::allocator_argument_tester
<ConstructiblePrefix
, 0> MarkType
;
931 typedef pair
<MarkType
, MarkType
> MarkTypePair
;
933 dummy
.~MarkTypePair();
934 s0i
.construct(&dummy
, piecewise_construct
, std::tuple
<>(), std::tuple
<>());
935 BOOST_TEST(dummy
.first
.construction_type
== ConstructiblePrefix
);
936 BOOST_TEST(dummy
.second
.construction_type
== ConstructiblePrefix
);
937 BOOST_TEST(dummy
.first
.value
== 0);
938 BOOST_TEST(dummy
.second
.value
== 0);
939 dummy
.~MarkTypePair();
942 typedef ::allocator_argument_tester
<NotUsesAllocator
, 0> MarkType
;
943 typedef pair
<MarkType
, MarkType
> MarkTypePair
;
945 dummy
.~MarkTypePair();
946 s0i
.construct(&dummy
, piecewise_construct
, std::tuple
<>(), std::tuple
<>());
947 BOOST_TEST(dummy
.first
.construction_type
== NotUsesAllocator
);
948 BOOST_TEST(dummy
.second
.construction_type
== NotUsesAllocator
);
949 BOOST_TEST(dummy
.first
.value
== 0);
950 BOOST_TEST(dummy
.second
.value
== 0);
951 dummy
.~MarkTypePair();
954 typedef ::allocator_argument_tester
<ConstructibleSuffix
, 0> MarkType
;
955 typedef pair
<MarkType
, MarkType
> MarkTypePair
;
957 dummy
.~MarkTypePair();
958 s0i
.construct(&dummy
, piecewise_construct
, std::tuple
<>(), std::tuple
<>());
959 BOOST_TEST(dummy
.first
.construction_type
== ConstructibleSuffix
);
960 BOOST_TEST(dummy
.second
.construction_type
== ConstructibleSuffix
);
961 BOOST_TEST(dummy
.first
.value
== 0);
962 BOOST_TEST(dummy
.second
.value
== 0);
963 dummy
.~MarkTypePair();
966 typedef ::allocator_argument_tester
<ConstructiblePrefix
, 0> MarkType
;
967 typedef pair
<MarkType
, MarkType
> MarkTypePair
;
969 dummy
.~MarkTypePair();
970 s0i
.construct(&dummy
, piecewise_construct
, std::tuple
<>(), std::tuple
<>());
971 BOOST_TEST(dummy
.first
.construction_type
== ConstructiblePrefix
);
972 BOOST_TEST(dummy
.second
.construction_type
== ConstructiblePrefix
);
973 BOOST_TEST(dummy
.first
.value
== 0);
974 BOOST_TEST(dummy
.second
.value
== 0);
975 dummy
.~MarkTypePair();
977 #endif //BOOST_CONTAINER_PAIR_TEST_HAS_HEADER_TUPLE
978 //Check construction with 1 user arguments for each pair
980 typedef ::allocator_argument_tester
<NotUsesAllocator
, 0> MarkType
;
981 typedef pair
<MarkType
, MarkType
> MarkTypePair
;
983 dummy
.~MarkTypePair();
984 s0i
.construct(&dummy
, 1, 1);
985 BOOST_TEST(dummy
.first
.construction_type
== NotUsesAllocator
);
986 BOOST_TEST(dummy
.second
.construction_type
== NotUsesAllocator
);
987 BOOST_TEST(dummy
.first
.value
== 1);
988 BOOST_TEST(dummy
.second
.value
== 1);
989 dummy
.~MarkTypePair();
992 typedef ::allocator_argument_tester
<ConstructibleSuffix
, 0> MarkType
;
993 typedef pair
<MarkType
, MarkType
> MarkTypePair
;
995 dummy
.~MarkTypePair();
996 s0i
.construct(&dummy
, 1, 1);
997 BOOST_TEST(dummy
.first
.construction_type
== ConstructibleSuffix
);
998 BOOST_TEST(dummy
.second
.construction_type
== ConstructibleSuffix
);
999 BOOST_TEST(dummy
.first
.value
== 1);
1000 BOOST_TEST(dummy
.second
.value
== 1);
1001 dummy
.~MarkTypePair();
1004 typedef ::allocator_argument_tester
<ConstructiblePrefix
, 0> MarkType
;
1005 typedef pair
<MarkType
, MarkType
> MarkTypePair
;
1007 dummy
.~MarkTypePair();
1008 s0i
.construct(&dummy
, 2, 2);
1009 BOOST_TEST(dummy
.first
.construction_type
== ConstructiblePrefix
);
1010 BOOST_TEST(dummy
.second
.construction_type
== ConstructiblePrefix
);
1011 BOOST_TEST(dummy
.first
.value
== 2);
1012 BOOST_TEST(dummy
.second
.value
== 2);
1013 dummy
.~MarkTypePair();
1015 //Check construction with 1 user arguments for each pair and Boost tuple
1017 typedef ::allocator_argument_tester
<NotUsesAllocator
, 0> MarkType
;
1018 typedef pair
<MarkType
, MarkType
> MarkTypePair
;
1020 dummy
.~MarkTypePair();
1021 s0i
.construct(&dummy
, piecewise_construct
, boost::tuple
<int>(1), boost::tuple
<int>(1));
1022 BOOST_TEST(dummy
.first
.construction_type
== NotUsesAllocator
);
1023 BOOST_TEST(dummy
.second
.construction_type
== NotUsesAllocator
);
1024 BOOST_TEST(dummy
.first
.value
== 1);
1025 BOOST_TEST(dummy
.second
.value
== 1);
1026 dummy
.~MarkTypePair();
1029 typedef ::allocator_argument_tester
<ConstructibleSuffix
, 0> MarkType
;
1030 typedef pair
<MarkType
, MarkType
> MarkTypePair
;
1032 dummy
.~MarkTypePair();
1033 s0i
.construct(&dummy
, piecewise_construct
, boost::tuple
<int>(1), boost::tuple
<int>(1));
1034 BOOST_TEST(dummy
.first
.construction_type
== ConstructibleSuffix
);
1035 BOOST_TEST(dummy
.second
.construction_type
== ConstructibleSuffix
);
1036 BOOST_TEST(dummy
.first
.value
== 1);
1037 BOOST_TEST(dummy
.second
.value
== 1);
1038 dummy
.~MarkTypePair();
1041 typedef ::allocator_argument_tester
<ConstructiblePrefix
, 0> MarkType
;
1042 typedef pair
<MarkType
, MarkType
> MarkTypePair
;
1044 dummy
.~MarkTypePair();
1045 s0i
.construct(&dummy
, piecewise_construct
, boost::tuple
<int>(2), boost::tuple
<int>(2));
1046 BOOST_TEST(dummy
.first
.construction_type
== ConstructiblePrefix
);
1047 BOOST_TEST(dummy
.second
.construction_type
== ConstructiblePrefix
);
1048 BOOST_TEST(dummy
.first
.value
== 2);
1049 BOOST_TEST(dummy
.second
.value
== 2);
1050 dummy
.~MarkTypePair();
1052 #if defined(BOOST_CONTAINER_PAIR_TEST_HAS_HEADER_TUPLE)
1053 //Check construction with 1 user arguments for each pair and Boost tuple
1055 typedef ::allocator_argument_tester
<NotUsesAllocator
, 0> MarkType
;
1056 typedef pair
<MarkType
, MarkType
> MarkTypePair
;
1058 dummy
.~MarkTypePair();
1059 s0i
.construct(&dummy
, piecewise_construct
, std::tuple
<int>(1), std::tuple
<int>(1));
1060 BOOST_TEST(dummy
.first
.construction_type
== NotUsesAllocator
);
1061 BOOST_TEST(dummy
.second
.construction_type
== NotUsesAllocator
);
1062 BOOST_TEST(dummy
.first
.value
== 1);
1063 BOOST_TEST(dummy
.second
.value
== 1);
1064 dummy
.~MarkTypePair();
1067 typedef ::allocator_argument_tester
<ConstructibleSuffix
, 0> MarkType
;
1068 typedef pair
<MarkType
, MarkType
> MarkTypePair
;
1070 dummy
.~MarkTypePair();
1071 s0i
.construct(&dummy
, piecewise_construct
, std::tuple
<int>(1), std::tuple
<int>(1));
1072 BOOST_TEST(dummy
.first
.construction_type
== ConstructibleSuffix
);
1073 BOOST_TEST(dummy
.second
.construction_type
== ConstructibleSuffix
);
1074 BOOST_TEST(dummy
.first
.value
== 1);
1075 BOOST_TEST(dummy
.second
.value
== 1);
1076 dummy
.~MarkTypePair();
1079 typedef ::allocator_argument_tester
<ConstructiblePrefix
, 0> MarkType
;
1080 typedef pair
<MarkType
, MarkType
> MarkTypePair
;
1082 dummy
.~MarkTypePair();
1083 s0i
.construct(&dummy
, piecewise_construct
, std::tuple
<int>(2), std::tuple
<int>(2));
1084 BOOST_TEST(dummy
.first
.construction_type
== ConstructiblePrefix
);
1085 BOOST_TEST(dummy
.second
.construction_type
== ConstructiblePrefix
);
1086 BOOST_TEST(dummy
.first
.value
== 2);
1087 BOOST_TEST(dummy
.second
.value
== 2);
1088 dummy
.~MarkTypePair();
1090 #endif //BOOST_CONTAINER_PAIR_TEST_HAS_HEADER_TUPLE
1091 //Check construction with pair copy construction
1093 typedef ::allocator_argument_tester
<NotUsesAllocator
, 0> MarkType
;
1094 typedef pair
<MarkType
, MarkType
> MarkTypePair
;
1095 MarkTypePair dummy
, dummy2
;
1096 dummy
.~MarkTypePair();
1097 s0i
.construct(&dummy
, dummy2
);
1098 BOOST_TEST(dummy
.first
.construction_type
== NotUsesAllocator
);
1099 BOOST_TEST(dummy
.second
.construction_type
== NotUsesAllocator
);
1100 BOOST_TEST(dummy
.first
.value
== 0);
1101 BOOST_TEST(dummy
.second
.value
== 0);
1102 dummy
.~MarkTypePair();
1105 typedef ::allocator_argument_tester
<ConstructibleSuffix
, 0> MarkType
;
1106 typedef pair
<MarkType
, MarkType
> MarkTypePair
;
1107 MarkTypePair dummy
, dummy2(1, 1);
1108 dummy
.~MarkTypePair();
1109 s0i
.construct(&dummy
, dummy2
);
1110 BOOST_TEST(dummy
.first
.construction_type
== ConstructibleSuffix
);
1111 BOOST_TEST(dummy
.second
.construction_type
== ConstructibleSuffix
);
1112 BOOST_TEST(dummy
.first
.value
== 1);
1113 BOOST_TEST(dummy
.second
.value
== 1);
1114 dummy
.~MarkTypePair();
1117 typedef ::allocator_argument_tester
<ConstructiblePrefix
, 0> MarkType
;
1118 typedef pair
<MarkType
, MarkType
> MarkTypePair
;
1119 MarkTypePair dummy
, dummy2(2, 2);
1120 dummy
.~MarkTypePair();
1121 s0i
.construct(&dummy
, dummy2
);
1122 BOOST_TEST(dummy
.first
.construction_type
== ConstructiblePrefix
);
1123 BOOST_TEST(dummy
.second
.construction_type
== ConstructiblePrefix
);
1124 BOOST_TEST(dummy
.first
.value
== 2);
1125 BOOST_TEST(dummy
.second
.value
== 2);
1126 dummy
.~MarkTypePair();
1128 //Check construction with pair move construction
1130 typedef ::allocator_argument_tester
<NotUsesAllocator
, 0> MarkType
;
1131 typedef pair
<MarkType
, MarkType
> MarkTypePair
;
1132 MarkTypePair dummy
, dummy2(3, 3);
1133 dummy2
.first
.construction_type
= dummy2
.second
.construction_type
= ConstructibleSuffix
;
1134 dummy
.~MarkTypePair();
1135 s0i
.construct(&dummy
, ::boost::move(dummy2
));
1136 BOOST_TEST(dummy
.first
.construction_type
== NotUsesAllocator
);
1137 BOOST_TEST(dummy
.second
.construction_type
== NotUsesAllocator
);
1138 BOOST_TEST(dummy
.first
.value
== 3);
1139 BOOST_TEST(dummy
.second
.value
== 3);
1140 BOOST_TEST(dummy2
.first
.construction_type
== NotUsesAllocator
);
1141 BOOST_TEST(dummy2
.second
.construction_type
== NotUsesAllocator
);
1142 BOOST_TEST(dummy2
.first
.value
== 0);
1143 BOOST_TEST(dummy2
.second
.value
== 0);
1144 dummy
.~MarkTypePair();
1147 typedef ::allocator_argument_tester
<ConstructibleSuffix
, 0> MarkType
;
1148 typedef pair
<MarkType
, MarkType
> MarkTypePair
;
1149 MarkTypePair dummy
, dummy2(1, 1);
1150 dummy
.~MarkTypePair();
1151 s0i
.construct(&dummy
, ::boost::move(dummy2
));
1152 BOOST_TEST(dummy
.first
.construction_type
== ConstructibleSuffix
);
1153 BOOST_TEST(dummy
.second
.construction_type
== ConstructibleSuffix
);
1154 BOOST_TEST(dummy
.first
.value
== 1);
1155 BOOST_TEST(dummy
.second
.value
== 1);
1156 BOOST_TEST(dummy2
.first
.construction_type
== ConstructibleSuffix
);
1157 BOOST_TEST(dummy2
.second
.construction_type
== ConstructibleSuffix
);
1158 BOOST_TEST(dummy2
.first
.value
== 0);
1159 BOOST_TEST(dummy2
.second
.value
== 0);
1160 dummy
.~MarkTypePair();
1163 typedef ::allocator_argument_tester
<ConstructiblePrefix
, 0> MarkType
;
1164 typedef pair
<MarkType
, MarkType
> MarkTypePair
;
1165 MarkTypePair dummy
, dummy2(2, 2);
1166 dummy
.~MarkTypePair();
1167 s0i
.construct(&dummy
, ::boost::move(dummy2
));
1168 BOOST_TEST(dummy
.first
.construction_type
== ConstructiblePrefix
);
1169 BOOST_TEST(dummy
.second
.construction_type
== ConstructiblePrefix
);
1170 BOOST_TEST(dummy
.first
.value
== 2);
1171 BOOST_TEST(dummy
.second
.value
== 2);
1172 BOOST_TEST(dummy2
.first
.construction_type
== ConstructiblePrefix
);
1173 BOOST_TEST(dummy2
.second
.construction_type
== ConstructiblePrefix
);
1174 BOOST_TEST(dummy2
.first
.value
== 0);
1175 BOOST_TEST(dummy2
.second
.value
== 0);
1176 dummy
.~MarkTypePair();
1178 //Check construction with related pair copy construction
1180 typedef ::allocator_argument_tester
<NotUsesAllocator
, 0> MarkType
;
1181 typedef pair
<MarkType
, MarkType
> MarkTypePair
;
1183 pair
<int, int> dummy2
;
1184 dummy
.~MarkTypePair();
1185 s0i
.construct(&dummy
, dummy2
);
1186 BOOST_TEST(dummy
.first
.construction_type
== NotUsesAllocator
);
1187 BOOST_TEST(dummy
.second
.construction_type
== NotUsesAllocator
);
1188 BOOST_TEST(dummy
.first
.value
== 0);
1189 BOOST_TEST(dummy
.second
.value
== 0);
1190 dummy
.~MarkTypePair();
1193 typedef ::allocator_argument_tester
<ConstructibleSuffix
, 0> MarkType
;
1194 typedef pair
<MarkType
, MarkType
> MarkTypePair
;
1196 pair
<int, int> dummy2(1, 1);
1197 dummy
.~MarkTypePair();
1198 s0i
.construct(&dummy
, dummy2
);
1199 BOOST_TEST(dummy
.first
.construction_type
== ConstructibleSuffix
);
1200 BOOST_TEST(dummy
.second
.construction_type
== ConstructibleSuffix
);
1201 BOOST_TEST(dummy
.first
.value
== 1);
1202 BOOST_TEST(dummy
.second
.value
== 1);
1203 dummy
.~MarkTypePair();
1206 typedef ::allocator_argument_tester
<ConstructiblePrefix
, 0> MarkType
;
1207 typedef pair
<MarkType
, MarkType
> MarkTypePair
;
1209 pair
<int, int> dummy2(2, 2);
1210 dummy
.~MarkTypePair();
1211 s0i
.construct(&dummy
, dummy2
);
1212 BOOST_TEST(dummy
.first
.construction_type
== ConstructiblePrefix
);
1213 BOOST_TEST(dummy
.second
.construction_type
== ConstructiblePrefix
);
1214 BOOST_TEST(dummy
.first
.value
== 2);
1215 BOOST_TEST(dummy
.second
.value
== 2);
1216 dummy
.~MarkTypePair();
1218 //Check construction with related pair move construction
1220 typedef ::allocator_argument_tester
<NotUsesAllocator
, 0> MarkType
;
1221 typedef pair
<MarkType
, MarkType
> MarkTypePair
;
1223 pair
<int, int> dummy2(3, 3);
1224 dummy
.~MarkTypePair();
1225 s0i
.construct(&dummy
, ::boost::move(dummy2
));
1226 BOOST_TEST(dummy
.first
.construction_type
== NotUsesAllocator
);
1227 BOOST_TEST(dummy
.second
.construction_type
== NotUsesAllocator
);
1228 BOOST_TEST(dummy
.first
.value
== 3);
1229 BOOST_TEST(dummy
.second
.value
== 3);
1230 dummy
.~MarkTypePair();
1233 typedef ::allocator_argument_tester
<ConstructibleSuffix
, 0> MarkType
;
1234 typedef pair
<MarkType
, MarkType
> MarkTypePair
;
1236 pair
<int, int> dummy2(1, 1);
1237 dummy
.~MarkTypePair();
1238 s0i
.construct(&dummy
, ::boost::move(dummy2
));
1239 BOOST_TEST(dummy
.first
.construction_type
== ConstructibleSuffix
);
1240 BOOST_TEST(dummy
.second
.construction_type
== ConstructibleSuffix
);
1241 BOOST_TEST(dummy
.first
.value
== 1);
1242 BOOST_TEST(dummy
.second
.value
== 1);
1243 dummy
.~MarkTypePair();
1246 typedef ::allocator_argument_tester
<ConstructiblePrefix
, 0> MarkType
;
1247 typedef pair
<MarkType
, MarkType
> MarkTypePair
;
1249 pair
<int, int> dummy2(2, 2);
1250 dummy
.~MarkTypePair();
1251 s0i
.construct(&dummy
, ::boost::move(dummy2
));
1252 BOOST_TEST(dummy
.first
.construction_type
== ConstructiblePrefix
);
1253 BOOST_TEST(dummy
.second
.construction_type
== ConstructiblePrefix
);
1254 BOOST_TEST(dummy
.first
.value
== 2);
1255 BOOST_TEST(dummy
.second
.value
== 2);
1256 dummy
.~MarkTypePair();
1258 //Check construction with 0/1 arguments for each pair and Boost tuple
1260 typedef ::allocator_argument_tester
<NotUsesAllocator
, 0> MarkType
;
1261 typedef pair
<MarkType
, MarkType
> MarkTypePair
;
1263 dummy
.~MarkTypePair();
1264 s0i
.construct(&dummy
, piecewise_construct
, boost::tuple
<>(), boost::tuple
<int>(1));
1265 BOOST_TEST(dummy
.first
.construction_type
== NotUsesAllocator
);
1266 BOOST_TEST(dummy
.second
.construction_type
== NotUsesAllocator
);
1267 BOOST_TEST(dummy
.first
.value
== 0);
1268 BOOST_TEST(dummy
.second
.value
== 1);
1269 dummy
.~MarkTypePair();
1272 typedef ::allocator_argument_tester
<ConstructibleSuffix
, 0> MarkType
;
1273 typedef pair
<MarkType
, MarkType
> MarkTypePair
;
1275 dummy
.~MarkTypePair();
1276 s0i
.construct(&dummy
, piecewise_construct
, boost::tuple
<int>(1), boost::tuple
<>());
1277 BOOST_TEST(dummy
.first
.construction_type
== ConstructibleSuffix
);
1278 BOOST_TEST(dummy
.second
.construction_type
== ConstructibleSuffix
);
1279 BOOST_TEST(dummy
.first
.value
== 1);
1280 BOOST_TEST(dummy
.second
.value
== 0);
1281 dummy
.~MarkTypePair();
1284 typedef ::allocator_argument_tester
<ConstructiblePrefix
, 0> MarkType
;
1285 typedef pair
<MarkType
, MarkType
> MarkTypePair
;
1287 dummy
.~MarkTypePair();
1288 s0i
.construct(&dummy
, piecewise_construct
, boost::tuple
<>(), boost::tuple
<int>(2));
1289 BOOST_TEST(dummy
.first
.construction_type
== ConstructiblePrefix
);
1290 BOOST_TEST(dummy
.second
.construction_type
== ConstructiblePrefix
);
1291 BOOST_TEST(dummy
.first
.value
== 0);
1292 BOOST_TEST(dummy
.second
.value
== 2);
1293 dummy
.~MarkTypePair();
1295 #if defined(BOOST_CONTAINER_PAIR_TEST_HAS_HEADER_TUPLE)
1296 //Check construction with 0/1 arguments for each pair and Boost tuple
1298 typedef ::allocator_argument_tester
<NotUsesAllocator
, 0> MarkType
;
1299 typedef pair
<MarkType
, MarkType
> MarkTypePair
;
1301 dummy
.~MarkTypePair();
1302 s0i
.construct(&dummy
, piecewise_construct
, std::tuple
<>(), std::tuple
<int>(1));
1303 BOOST_TEST(dummy
.first
.construction_type
== NotUsesAllocator
);
1304 BOOST_TEST(dummy
.second
.construction_type
== NotUsesAllocator
);
1305 BOOST_TEST(dummy
.first
.value
== 0);
1306 BOOST_TEST(dummy
.second
.value
== 1);
1307 dummy
.~MarkTypePair();
1310 typedef ::allocator_argument_tester
<ConstructibleSuffix
, 0> MarkType
;
1311 typedef pair
<MarkType
, MarkType
> MarkTypePair
;
1313 dummy
.~MarkTypePair();
1314 s0i
.construct(&dummy
, piecewise_construct
, std::tuple
<int>(1), std::tuple
<>());
1315 BOOST_TEST(dummy
.first
.construction_type
== ConstructibleSuffix
);
1316 BOOST_TEST(dummy
.second
.construction_type
== ConstructibleSuffix
);
1317 BOOST_TEST(dummy
.first
.value
== 1);
1318 BOOST_TEST(dummy
.second
.value
== 0);
1319 dummy
.~MarkTypePair();
1322 typedef ::allocator_argument_tester
<ConstructiblePrefix
, 0> MarkType
;
1323 typedef pair
<MarkType
, MarkType
> MarkTypePair
;
1325 dummy
.~MarkTypePair();
1326 s0i
.construct(&dummy
, piecewise_construct
, std::tuple
<>(), std::tuple
<int>(2));
1327 BOOST_TEST(dummy
.first
.construction_type
== ConstructiblePrefix
);
1328 BOOST_TEST(dummy
.second
.construction_type
== ConstructiblePrefix
);
1329 BOOST_TEST(dummy
.first
.value
== 0);
1330 BOOST_TEST(dummy
.second
.value
== 2);
1331 dummy
.~MarkTypePair();
1333 #endif //BOOST_CONTAINER_PAIR_TEST_HAS_HEADER_TUPLE
1335 //Check construction with try_emplace_t 0/1 arguments for each pair
1337 typedef ::allocator_argument_tester
<NotUsesAllocator
, 0> MarkType
;
1338 typedef pair
<MarkType
, MarkType
> MarkTypePair
;
1340 dummy
.~MarkTypePair();
1341 s0i
.construct(&dummy
, try_emplace_t(), 5, 1);
1342 BOOST_TEST(dummy
.first
.construction_type
== NotUsesAllocator
);
1343 BOOST_TEST(dummy
.second
.construction_type
== NotUsesAllocator
);
1344 BOOST_TEST(dummy
.first
.value
== 5);
1345 BOOST_TEST(dummy
.second
.value
== 1);
1346 dummy
.~MarkTypePair();
1349 typedef ::allocator_argument_tester
<ConstructibleSuffix
, 0> MarkType
;
1350 typedef pair
<MarkType
, MarkType
> MarkTypePair
;
1352 dummy
.~MarkTypePair();
1353 s0i
.construct(&dummy
, try_emplace_t(), 6);
1354 BOOST_TEST(dummy
.first
.construction_type
== ConstructibleSuffix
);
1355 BOOST_TEST(dummy
.second
.construction_type
== ConstructibleSuffix
);
1356 BOOST_TEST(dummy
.first
.value
== 6);
1357 BOOST_TEST(dummy
.second
.value
== 0);
1358 dummy
.~MarkTypePair();
1361 typedef ::allocator_argument_tester
<ConstructiblePrefix
, 0> MarkType
;
1362 typedef pair
<MarkType
, MarkType
> MarkTypePair
;
1364 dummy
.~MarkTypePair();
1365 s0i
.construct(&dummy
, try_emplace_t(), 7, 2);
1366 BOOST_TEST(dummy
.first
.construction_type
== ConstructiblePrefix
);
1367 BOOST_TEST(dummy
.second
.construction_type
== ConstructiblePrefix
);
1368 BOOST_TEST(dummy
.first
.value
== 7);
1369 BOOST_TEST(dummy
.second
.value
== 2);
1370 dummy
.~MarkTypePair();
1375 return ::boost::report_errors();
1377 #include <boost/container/detail/config_end.hpp>