1//////////////////////////////////////////////////////////////////////////////
2//
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)
6//
7// See http://www.boost.org/libs/container for documentation.
8//
9//////////////////////////////////////////////////////////////////////////////
10#include <boost/container/scoped_allocator_fwd.hpp>
11
12// container/detail
13#include <boost/container/detail/mpl.hpp>
14// move
15#include <boost/move/utility_core.hpp>
16#include <boost/move/adl_move_swap.hpp>
17//boost
18#include <boost/tuple/tuple.hpp>
19// std
20#include <memory>
21#include <cstddef>
22
23#if defined(BOOST_CONTAINER_PAIR_TEST_HAS_HEADER_TUPLE)
24#include <tuple>
25#endif
26
27//test
28#include <boost/core/lightweight_test.hpp>
29
30#include "allocator_argument_tester.hpp"
31
32template<unsigned int Type>
33struct tagged_integer
34{};
35
36struct mark_on_destructor
37{
38 mark_on_destructor()
39 {
40 destroyed = false;
41 }
42
43 ~mark_on_destructor()
44 {
45 destroyed = true;
46 }
47
48 static bool destroyed;
49};
50
51bool mark_on_destructor::destroyed = false;
52
53#include <boost/container/scoped_allocator.hpp>
54#include <boost/container/vector.hpp>
55#include <boost/container/detail/pair.hpp>
56
57int main()
58{
59 using namespace boost::container;
60
61 typedef propagation_test_allocator<tagged_integer<0>, 0> OuterAlloc;
62 typedef propagation_test_allocator<tagged_integer<0>, 10> Outer10IdAlloc;
63 typedef propagation_test_allocator<tagged_integer<9>, 0> Rebound9OuterAlloc;
64 typedef propagation_test_allocator<tagged_integer<1>, 1> InnerAlloc1;
65 typedef propagation_test_allocator<tagged_integer<2>, 2> InnerAlloc2;
66 typedef propagation_test_allocator<tagged_integer<1>, 11> Inner11IdAlloc1;
67
68 typedef propagation_test_allocator<tagged_integer<0>, 0, false> OuterAllocFalseHasTrueTypes;
69 typedef propagation_test_allocator<tagged_integer<0>, 0, true> OuterAllocTrueHasTrueTypes;
70 typedef propagation_test_allocator<tagged_integer<1>, 1, false> InnerAlloc1FalseHasTrueTypes;
71 typedef propagation_test_allocator<tagged_integer<1>, 1, true> InnerAlloc1TrueHasTrueTypes;
72 typedef propagation_test_allocator<tagged_integer<2>, 2, false> InnerAlloc2FalseHasTrueTypes;
73 typedef propagation_test_allocator<tagged_integer<2>, 2, true> InnerAlloc2TrueHasTrueTypes;
74
75 //
76 typedef scoped_allocator_adaptor< OuterAlloc > Scoped0Inner;
77 typedef scoped_allocator_adaptor< OuterAlloc
78 , InnerAlloc1 > Scoped1Inner;
79 typedef scoped_allocator_adaptor< OuterAlloc
80 , InnerAlloc1
81 , InnerAlloc2 > Scoped2Inner;
82 typedef scoped_allocator_adaptor
83 < scoped_allocator_adaptor
84 <Outer10IdAlloc>
85 > ScopedScoped0Inner;
86 typedef scoped_allocator_adaptor
87 < scoped_allocator_adaptor
88 <Outer10IdAlloc, Inner11IdAlloc1>
89 , InnerAlloc1
90 > ScopedScoped1Inner;
91 typedef scoped_allocator_adaptor< Rebound9OuterAlloc > Rebound9Scoped0Inner;
92 typedef scoped_allocator_adaptor< Rebound9OuterAlloc
93 , InnerAlloc1 > Rebound9Scoped1Inner;
94 typedef scoped_allocator_adaptor< Rebound9OuterAlloc
95 , InnerAlloc1
96 , InnerAlloc2 > Rebound9Scoped2Inner;
97
98 //outer_allocator_type
99 BOOST_CONTAINER_STATIC_ASSERT(( dtl::is_same< OuterAlloc
100 , Scoped0Inner::outer_allocator_type>::value ));
101 BOOST_CONTAINER_STATIC_ASSERT(( dtl::is_same< OuterAlloc
102 , Scoped1Inner::outer_allocator_type>::value ));
103 BOOST_CONTAINER_STATIC_ASSERT(( dtl::is_same< OuterAlloc
104 , Scoped2Inner::outer_allocator_type>::value ));
105 //value_type
106 BOOST_CONTAINER_STATIC_ASSERT(( dtl::is_same< allocator_traits<OuterAlloc>::value_type
107 , Scoped0Inner::value_type>::value ));
108 BOOST_CONTAINER_STATIC_ASSERT(( dtl::is_same< allocator_traits<OuterAlloc>::value_type
109 , Scoped1Inner::value_type>::value ));
110 BOOST_CONTAINER_STATIC_ASSERT(( dtl::is_same< allocator_traits<OuterAlloc>::value_type
111 , Scoped2Inner::value_type>::value ));
112 //size_type
113 BOOST_CONTAINER_STATIC_ASSERT(( dtl::is_same< allocator_traits<OuterAlloc>::size_type
114 , Scoped0Inner::size_type>::value ));
115 BOOST_CONTAINER_STATIC_ASSERT(( dtl::is_same< allocator_traits<OuterAlloc>::size_type
116 , Scoped1Inner::size_type>::value ));
117 BOOST_CONTAINER_STATIC_ASSERT(( dtl::is_same< allocator_traits<OuterAlloc>::size_type
118 , Scoped2Inner::size_type>::value ));
119
120 //difference_type
121 BOOST_CONTAINER_STATIC_ASSERT(( dtl::is_same< allocator_traits<OuterAlloc>::difference_type
122 , Scoped0Inner::difference_type>::value ));
123 BOOST_CONTAINER_STATIC_ASSERT(( dtl::is_same< allocator_traits<OuterAlloc>::difference_type
124 , Scoped1Inner::difference_type>::value ));
125 BOOST_CONTAINER_STATIC_ASSERT(( dtl::is_same< allocator_traits<OuterAlloc>::difference_type
126 , Scoped2Inner::difference_type>::value ));
127
128 //pointer
129 BOOST_CONTAINER_STATIC_ASSERT(( dtl::is_same< allocator_traits<OuterAlloc>::pointer
130 , Scoped0Inner::pointer>::value ));
131 BOOST_CONTAINER_STATIC_ASSERT(( dtl::is_same< allocator_traits<OuterAlloc>::pointer
132 , Scoped1Inner::pointer>::value ));
133 BOOST_CONTAINER_STATIC_ASSERT(( dtl::is_same< allocator_traits<OuterAlloc>::pointer
134 , Scoped2Inner::pointer>::value ));
135
136 //const_pointer
137 BOOST_CONTAINER_STATIC_ASSERT(( dtl::is_same< allocator_traits<OuterAlloc>::const_pointer
138 , Scoped0Inner::const_pointer>::value ));
139 BOOST_CONTAINER_STATIC_ASSERT(( dtl::is_same< allocator_traits<OuterAlloc>::const_pointer
140 , Scoped1Inner::const_pointer>::value ));
141 BOOST_CONTAINER_STATIC_ASSERT(( dtl::is_same< allocator_traits<OuterAlloc>::const_pointer
142 , Scoped2Inner::const_pointer>::value ));
143
144 //void_pointer
145 BOOST_CONTAINER_STATIC_ASSERT(( dtl::is_same< allocator_traits<OuterAlloc>::void_pointer
146 , Scoped0Inner::void_pointer>::value ));
147 BOOST_CONTAINER_STATIC_ASSERT(( dtl::is_same< allocator_traits<OuterAlloc>::void_pointer
148 , Scoped1Inner::void_pointer>::value ));
149 BOOST_CONTAINER_STATIC_ASSERT(( dtl::is_same< allocator_traits<OuterAlloc>::void_pointer
150 , Scoped2Inner::void_pointer>::value ));
151
152 //const_void_pointer
153 BOOST_CONTAINER_STATIC_ASSERT(( dtl::is_same< allocator_traits<OuterAlloc>::const_void_pointer
154 , Scoped0Inner::const_void_pointer>::value ));
155 BOOST_CONTAINER_STATIC_ASSERT(( dtl::is_same< allocator_traits<OuterAlloc>::const_void_pointer
156 , Scoped1Inner::const_void_pointer>::value ));
157 BOOST_CONTAINER_STATIC_ASSERT(( dtl::is_same< allocator_traits<OuterAlloc>::const_void_pointer
158 , Scoped2Inner::const_void_pointer>::value ));
159
160 //rebind
161 BOOST_CONTAINER_STATIC_ASSERT(( dtl::is_same<Scoped0Inner::rebind< tagged_integer<9> >::other
162 , Rebound9Scoped0Inner >::value ));
163 BOOST_CONTAINER_STATIC_ASSERT(( dtl::is_same<Scoped1Inner::rebind< tagged_integer<9> >::other
164 , Rebound9Scoped1Inner >::value ));
165 BOOST_CONTAINER_STATIC_ASSERT(( dtl::is_same<Scoped2Inner::rebind< tagged_integer<9> >::other
166 , Rebound9Scoped2Inner >::value ));
167
168 //inner_allocator_type
169 BOOST_CONTAINER_STATIC_ASSERT(( dtl::is_same< Scoped0Inner
170 , Scoped0Inner::inner_allocator_type>::value ));
171 BOOST_CONTAINER_STATIC_ASSERT(( dtl::is_same< scoped_allocator_adaptor<InnerAlloc1>
172 , Scoped1Inner::inner_allocator_type>::value ));
173 BOOST_CONTAINER_STATIC_ASSERT(( dtl::is_same< scoped_allocator_adaptor<InnerAlloc1, InnerAlloc2>
174 , Scoped2Inner::inner_allocator_type>::value ));
175
176 {
177 //Propagation test
178 typedef scoped_allocator_adaptor< OuterAllocFalseHasTrueTypes > Scoped0InnerF;
179 typedef scoped_allocator_adaptor< OuterAllocTrueHasTrueTypes > Scoped0InnerT;
180 typedef scoped_allocator_adaptor< OuterAllocFalseHasTrueTypes
181 , InnerAlloc1FalseHasTrueTypes > Scoped1InnerFF;
182 typedef scoped_allocator_adaptor< OuterAllocFalseHasTrueTypes
183 , InnerAlloc1TrueHasTrueTypes > Scoped1InnerFT;
184 typedef scoped_allocator_adaptor< OuterAllocTrueHasTrueTypes
185 , InnerAlloc1FalseHasTrueTypes > Scoped1InnerTF;
186 typedef scoped_allocator_adaptor< OuterAllocTrueHasTrueTypes
187 , InnerAlloc1TrueHasTrueTypes > Scoped1InnerTT;
188 typedef scoped_allocator_adaptor< OuterAllocFalseHasTrueTypes
189 , InnerAlloc1FalseHasTrueTypes
190 , InnerAlloc2FalseHasTrueTypes > Scoped2InnerFFF;
191 typedef scoped_allocator_adaptor< OuterAllocFalseHasTrueTypes
192 , InnerAlloc1FalseHasTrueTypes
193 , InnerAlloc2TrueHasTrueTypes > Scoped2InnerFFT;
194 typedef scoped_allocator_adaptor< OuterAllocFalseHasTrueTypes
195 , InnerAlloc1TrueHasTrueTypes
196 , InnerAlloc2FalseHasTrueTypes > Scoped2InnerFTF;
197 typedef scoped_allocator_adaptor< OuterAllocFalseHasTrueTypes
198 , InnerAlloc1TrueHasTrueTypes
199 , InnerAlloc2TrueHasTrueTypes > Scoped2InnerFTT;
200 typedef scoped_allocator_adaptor< OuterAllocTrueHasTrueTypes
201 , InnerAlloc1FalseHasTrueTypes
202 , InnerAlloc2FalseHasTrueTypes > Scoped2InnerTFF;
203 typedef scoped_allocator_adaptor< OuterAllocTrueHasTrueTypes
204 , InnerAlloc1FalseHasTrueTypes
205 , InnerAlloc2TrueHasTrueTypes > Scoped2InnerTFT;
206 typedef scoped_allocator_adaptor< OuterAllocTrueHasTrueTypes
207 , InnerAlloc1TrueHasTrueTypes
208 , InnerAlloc2FalseHasTrueTypes > Scoped2InnerTTF;
209 typedef scoped_allocator_adaptor< OuterAllocTrueHasTrueTypes
210 , InnerAlloc1TrueHasTrueTypes
211 , InnerAlloc2TrueHasTrueTypes > Scoped2InnerTTT;
212
213 //propagate_on_container_copy_assignment
214 //0 inner
215 BOOST_CONTAINER_STATIC_ASSERT(( !Scoped0InnerF::propagate_on_container_copy_assignment::value ));
216 BOOST_CONTAINER_STATIC_ASSERT(( Scoped0InnerT::propagate_on_container_copy_assignment::value ));
217 //1 inner
218 BOOST_CONTAINER_STATIC_ASSERT(( !Scoped1InnerFF::propagate_on_container_copy_assignment::value ));
219 BOOST_CONTAINER_STATIC_ASSERT(( Scoped1InnerFT::propagate_on_container_copy_assignment::value ));
220 BOOST_CONTAINER_STATIC_ASSERT(( Scoped1InnerTF::propagate_on_container_copy_assignment::value ));
221 BOOST_CONTAINER_STATIC_ASSERT(( Scoped1InnerTT::propagate_on_container_copy_assignment::value ));
222 //2 inner
223 BOOST_CONTAINER_STATIC_ASSERT(( !Scoped2InnerFFF::propagate_on_container_copy_assignment::value ));
224 BOOST_CONTAINER_STATIC_ASSERT(( Scoped2InnerFFT::propagate_on_container_copy_assignment::value ));
225 BOOST_CONTAINER_STATIC_ASSERT(( Scoped2InnerFTF::propagate_on_container_copy_assignment::value ));
226 BOOST_CONTAINER_STATIC_ASSERT(( Scoped2InnerFTT::propagate_on_container_copy_assignment::value ));
227 BOOST_CONTAINER_STATIC_ASSERT(( Scoped2InnerTFF::propagate_on_container_copy_assignment::value ));
228 BOOST_CONTAINER_STATIC_ASSERT(( Scoped2InnerTFT::propagate_on_container_copy_assignment::value ));
229 BOOST_CONTAINER_STATIC_ASSERT(( Scoped2InnerTTF::propagate_on_container_copy_assignment::value ));
230 BOOST_CONTAINER_STATIC_ASSERT(( Scoped2InnerTTT::propagate_on_container_copy_assignment::value ));
231
232 //propagate_on_container_move_assignment
233 //0 inner
234 BOOST_CONTAINER_STATIC_ASSERT(( !Scoped0InnerF::propagate_on_container_move_assignment::value ));
235 BOOST_CONTAINER_STATIC_ASSERT(( Scoped0InnerT::propagate_on_container_move_assignment::value ));
236 //1 inner
237 BOOST_CONTAINER_STATIC_ASSERT(( !Scoped1InnerFF::propagate_on_container_move_assignment::value ));
238 BOOST_CONTAINER_STATIC_ASSERT(( Scoped1InnerFT::propagate_on_container_move_assignment::value ));
239 BOOST_CONTAINER_STATIC_ASSERT(( Scoped1InnerTF::propagate_on_container_move_assignment::value ));
240 BOOST_CONTAINER_STATIC_ASSERT(( Scoped1InnerTT::propagate_on_container_move_assignment::value ));
241 //2 inner
242 BOOST_CONTAINER_STATIC_ASSERT(( !Scoped2InnerFFF::propagate_on_container_move_assignment::value ));
243 BOOST_CONTAINER_STATIC_ASSERT(( Scoped2InnerFFT::propagate_on_container_move_assignment::value ));
244 BOOST_CONTAINER_STATIC_ASSERT(( Scoped2InnerFTF::propagate_on_container_move_assignment::value ));
245 BOOST_CONTAINER_STATIC_ASSERT(( Scoped2InnerFTT::propagate_on_container_move_assignment::value ));
246 BOOST_CONTAINER_STATIC_ASSERT(( Scoped2InnerTFF::propagate_on_container_move_assignment::value ));
247 BOOST_CONTAINER_STATIC_ASSERT(( Scoped2InnerTFT::propagate_on_container_move_assignment::value ));
248 BOOST_CONTAINER_STATIC_ASSERT(( Scoped2InnerTTF::propagate_on_container_move_assignment::value ));
249 BOOST_CONTAINER_STATIC_ASSERT(( Scoped2InnerTTT::propagate_on_container_move_assignment::value ));
250
251 //propagate_on_container_swap
252 //0 inner
253 BOOST_CONTAINER_STATIC_ASSERT(( !Scoped0InnerF::propagate_on_container_swap::value ));
254 BOOST_CONTAINER_STATIC_ASSERT(( Scoped0InnerT::propagate_on_container_swap::value ));
255 //1 inner
256 BOOST_CONTAINER_STATIC_ASSERT(( !Scoped1InnerFF::propagate_on_container_swap::value ));
257 BOOST_CONTAINER_STATIC_ASSERT(( Scoped1InnerFT::propagate_on_container_swap::value ));
258 BOOST_CONTAINER_STATIC_ASSERT(( Scoped1InnerTF::propagate_on_container_swap::value ));
259 BOOST_CONTAINER_STATIC_ASSERT(( Scoped1InnerTT::propagate_on_container_swap::value ));
260 //2 inner
261 BOOST_CONTAINER_STATIC_ASSERT(( !Scoped2InnerFFF::propagate_on_container_swap::value ));
262 BOOST_CONTAINER_STATIC_ASSERT(( Scoped2InnerFFT::propagate_on_container_swap::value ));
263 BOOST_CONTAINER_STATIC_ASSERT(( Scoped2InnerFTF::propagate_on_container_swap::value ));
264 BOOST_CONTAINER_STATIC_ASSERT(( Scoped2InnerFTT::propagate_on_container_swap::value ));
265 BOOST_CONTAINER_STATIC_ASSERT(( Scoped2InnerTFF::propagate_on_container_swap::value ));
266 BOOST_CONTAINER_STATIC_ASSERT(( Scoped2InnerTFT::propagate_on_container_swap::value ));
267 BOOST_CONTAINER_STATIC_ASSERT(( Scoped2InnerTTF::propagate_on_container_swap::value ));
268 BOOST_CONTAINER_STATIC_ASSERT(( Scoped2InnerTTT::propagate_on_container_swap::value ));
269 //is_always_equal
270 //0 inner
271 BOOST_CONTAINER_STATIC_ASSERT(( !Scoped0InnerF::is_always_equal::value ));
272 BOOST_CONTAINER_STATIC_ASSERT(( Scoped0InnerT::is_always_equal::value ));
273 //1 inner
274 BOOST_CONTAINER_STATIC_ASSERT(( !Scoped1InnerFF::is_always_equal::value ));
275 BOOST_CONTAINER_STATIC_ASSERT(( !Scoped1InnerFT::is_always_equal::value ));
276 BOOST_CONTAINER_STATIC_ASSERT(( !Scoped1InnerTF::is_always_equal::value ));
277 BOOST_CONTAINER_STATIC_ASSERT(( Scoped1InnerTT::is_always_equal::value ));
278 //2 inner
279 BOOST_CONTAINER_STATIC_ASSERT(( !Scoped2InnerFFF::is_always_equal::value ));
280 BOOST_CONTAINER_STATIC_ASSERT(( !Scoped2InnerFFT::is_always_equal::value ));
281 BOOST_CONTAINER_STATIC_ASSERT(( !Scoped2InnerFTF::is_always_equal::value ));
282 BOOST_CONTAINER_STATIC_ASSERT(( !Scoped2InnerFTT::is_always_equal::value ));
283 BOOST_CONTAINER_STATIC_ASSERT(( !Scoped2InnerTFF::is_always_equal::value ));
284 BOOST_CONTAINER_STATIC_ASSERT(( !Scoped2InnerTFT::is_always_equal::value ));
285 BOOST_CONTAINER_STATIC_ASSERT(( !Scoped2InnerTTF::is_always_equal::value ));
286 BOOST_CONTAINER_STATIC_ASSERT(( Scoped2InnerTTT::is_always_equal::value ));
287 }
288
289 //Default constructor
290 {
291 Scoped0Inner s0i;
292 Scoped1Inner s1i;
293 //Swap
294 {
295 Scoped0Inner s0i2;
296 Scoped1Inner s1i2;
297 boost::adl_move_swap(x&: s0i, y&: s0i2);
298 boost::adl_move_swap(x&: s1i, y&: s1i2);
299 }
300 }
301
302 //Default constructor
303 {
304 Scoped0Inner s0i;
305 Scoped1Inner s1i;
306 }
307
308 //Copy constructor/assignment
309 {
310 Scoped0Inner s0i;
311 Scoped1Inner s1i;
312 Scoped2Inner s2i;
313
314 Scoped0Inner s0i_b(s0i);
315 Scoped1Inner s1i_b(s1i);
316 Scoped2Inner s2i_b(s2i);
317
318 BOOST_TEST(s0i == s0i_b);
319 BOOST_TEST(s1i == s1i_b);
320 BOOST_TEST(s2i == s2i_b);
321
322 s0i_b = s0i;
323 s1i_b = s1i;
324 s2i_b = s2i;
325
326 BOOST_TEST(s0i == s0i_b);
327 BOOST_TEST(s1i == s1i_b);
328 BOOST_TEST(s2i == s2i_b);
329 }
330
331 //Copy/move constructor/assignment
332 {
333 Scoped0Inner s0i;
334 Scoped1Inner s1i;
335 Scoped2Inner s2i;
336
337 Scoped0Inner s0i_b(::boost::move(t&: s0i));
338 Scoped1Inner s1i_b(::boost::move(t&: s1i));
339 Scoped2Inner s2i_b(::boost::move(t&: s2i));
340
341 BOOST_TEST(s0i_b.outer_allocator().m_move_contructed);
342 BOOST_TEST(s1i_b.outer_allocator().m_move_contructed);
343 BOOST_TEST(s2i_b.outer_allocator().m_move_contructed);
344
345 s0i_b = ::boost::move(t&: s0i);
346 s1i_b = ::boost::move(t&: s1i);
347 s2i_b = ::boost::move(t&: s2i);
348
349 BOOST_TEST(s0i_b.outer_allocator().m_move_assigned);
350 BOOST_TEST(s1i_b.outer_allocator().m_move_assigned);
351 BOOST_TEST(s2i_b.outer_allocator().m_move_assigned);
352 }
353
354 //inner_allocator()
355 {
356 Scoped0Inner s0i;
357 Scoped1Inner s1i;
358 Scoped2Inner s2i;
359 const Scoped0Inner const_s0i;
360 const Scoped1Inner const_s1i;
361 const Scoped2Inner const_s2i;
362
363 Scoped0Inner::inner_allocator_type &s0i_inner = s0i.inner_allocator();
364 (void)s0i_inner;
365 const Scoped0Inner::inner_allocator_type &const_s0i_inner = const_s0i.inner_allocator();
366 (void)const_s0i_inner;
367 Scoped1Inner::inner_allocator_type &s1i_inner = s1i.inner_allocator();
368 (void)s1i_inner;
369 const Scoped1Inner::inner_allocator_type &const_s1i_inner = const_s1i.inner_allocator();
370 (void)const_s1i_inner;
371 Scoped2Inner::inner_allocator_type &s2i_inner = s2i.inner_allocator();
372 (void)s2i_inner;
373 const Scoped2Inner::inner_allocator_type &const_s2i_inner = const_s2i.inner_allocator();
374 (void)const_s2i_inner;
375 }
376
377 //operator==/!=
378 {
379 const Scoped0Inner const_s0i;
380 const Rebound9Scoped0Inner const_rs0i;
381
382 BOOST_TEST(const_s0i == const_s0i);
383 BOOST_TEST(const_rs0i == const_s0i);
384 BOOST_TEST(const_s0i == const_s0i);
385 BOOST_TEST(const_s0i == const_rs0i);
386
387 const Scoped1Inner const_s1i;
388 const Rebound9Scoped1Inner const_rs1i;
389
390 BOOST_TEST(const_s1i == const_s1i);
391 BOOST_TEST(const_rs1i == const_s1i);
392
393 BOOST_TEST(const_s1i == const_s1i);
394 BOOST_TEST(const_s1i == const_rs1i);
395
396 const Scoped2Inner const_s2i;
397 const Rebound9Scoped2Inner const_rs2i;
398
399 BOOST_TEST(const_s2i == const_s2i);
400 BOOST_TEST(const_s2i == const_rs2i);
401
402 BOOST_TEST(const_s2i == const_s2i);
403 BOOST_TEST(const_s2i == const_rs2i);
404 }
405
406 //outer_allocator()
407 {
408 Scoped0Inner s0i;
409 Scoped1Inner s1i;
410 Scoped2Inner s2i;
411 const Scoped0Inner const_s0i;
412 const Scoped1Inner const_s1i;
413 const Scoped2Inner const_s2i;
414
415 Scoped0Inner::outer_allocator_type &s0i_inner = s0i.outer_allocator();
416 (void)s0i_inner;
417 const Scoped0Inner::outer_allocator_type &const_s0i_inner = const_s0i.outer_allocator();
418 (void)const_s0i_inner;
419 Scoped1Inner::outer_allocator_type &s1i_inner = s1i.outer_allocator();
420 (void)s1i_inner;
421 const Scoped1Inner::outer_allocator_type &const_s1i_inner = const_s1i.outer_allocator();
422 (void)const_s1i_inner;
423 Scoped2Inner::outer_allocator_type &s2i_inner = s2i.outer_allocator();
424 (void)s2i_inner;
425 const Scoped2Inner::outer_allocator_type &const_s2i_inner = const_s2i.outer_allocator();
426 (void)const_s2i_inner;
427 }
428
429 //max_size()
430 {
431 const Scoped0Inner const_s0i;
432 const Scoped1Inner const_s1i;
433 const Scoped2Inner const_s2i;
434 const OuterAlloc const_oa;
435 const InnerAlloc1 const_ia1;
436 const InnerAlloc2 const_ia2;
437
438 BOOST_TEST(const_s0i.max_size() == const_oa.max_size());
439 BOOST_TEST(const_s1i.max_size() == const_oa.max_size());
440
441 BOOST_TEST(const_s2i.max_size() == const_oa.max_size());
442 BOOST_TEST(const_s1i.inner_allocator().max_size() == const_ia1.max_size());
443 BOOST_TEST(const_s2i.inner_allocator().inner_allocator().max_size() == const_ia2.max_size());
444 }
445 //Copy and move operations
446 {
447 //Construction
448 {
449 Scoped0Inner s0i_a, s0i_b(s0i_a), s0i_c(::boost::move(t&: s0i_b));
450 Scoped1Inner s1i_a, s1i_b(s1i_a), s1i_c(::boost::move(t&: s1i_b));
451 Scoped2Inner s2i_a, s2i_b(s2i_a), s2i_c(::boost::move(t&: s2i_b));
452 }
453 //Assignment
454 {
455 Scoped0Inner s0i_a, s0i_b;
456 s0i_a = s0i_b;
457 s0i_a = ::boost::move(t&: s0i_b);
458 Scoped1Inner s1i_a, s1i_b;
459 s1i_a = s1i_b;
460 s1i_a = ::boost::move(t&: s1i_b);
461 Scoped2Inner s2i_a, s2i_b;
462 s2i_a = s2i_b;
463 s2i_a = ::boost::move(t&: s2i_b);
464 }
465
466 OuterAlloc oa;
467 InnerAlloc1 ia1;
468 InnerAlloc2 ia2;
469 Rebound9OuterAlloc roa;
470 Rebound9Scoped0Inner rs0i;
471 Rebound9Scoped1Inner rs1i;
472 Rebound9Scoped2Inner rs2i;
473
474 //Copy from outer
475 {
476 Scoped0Inner s0i(oa);
477 Scoped1Inner s1i(oa, ia1);
478 Scoped2Inner s2i(oa, ia1, ia2);
479 }
480 //Move from outer
481 {
482 Scoped0Inner s0i(::boost::move(t&: oa));
483 Scoped1Inner s1i(::boost::move(t&: oa), ia1);
484 Scoped2Inner s2i(::boost::move(t&: oa), ia1, ia2);
485 }
486 //Copy from rebound outer
487 {
488 Scoped0Inner s0i(roa);
489 Scoped1Inner s1i(roa, ia1);
490 Scoped2Inner s2i(roa, ia1, ia2);
491 }
492 //Move from rebound outer
493 {
494 Scoped0Inner s0i(::boost::move(t&: roa));
495 Scoped1Inner s1i(::boost::move(t&: roa), ia1);
496 Scoped2Inner s2i(::boost::move(t&: roa), ia1, ia2);
497 }
498 //Copy from rebound scoped
499 {
500 Scoped0Inner s0i(rs0i);
501 Scoped1Inner s1i(rs1i);
502 Scoped2Inner s2i(rs2i);
503 }
504 //Move from rebound scoped
505 {
506 Scoped0Inner s0i(::boost::move(t&: rs0i));
507 Scoped1Inner s1i(::boost::move(t&: rs1i));
508 Scoped2Inner s2i(::boost::move(t&: rs2i));
509 }
510 }
511
512 {
513 vector<int, scoped_allocator_adaptor< propagation_test_allocator<int, 0> > > dummy;
514 dummy.push_back(x: 0);
515 }
516
517 //destroy()
518 {
519 {
520 Scoped0Inner s0i;
521 mark_on_destructor mod;
522 s0i.destroy(p: &mod);
523 BOOST_TEST(mark_on_destructor::destroyed);
524 }
525
526 {
527 Scoped1Inner s1i;
528 mark_on_destructor mod;
529 s1i.destroy(p: &mod);
530 BOOST_TEST(mark_on_destructor::destroyed);
531 }
532 {
533 Scoped2Inner s2i;
534 mark_on_destructor mod;
535 s2i.destroy(p: &mod);
536 BOOST_TEST(mark_on_destructor::destroyed);
537 }
538 }
539
540 //construct
541 {
542 ////////////////////////////////////////////////////////////
543 //First check scoped allocator with just OuterAlloc.
544 //In this case OuterAlloc (propagation_test_allocator with tag 0) should be
545 //used to construct types.
546 ////////////////////////////////////////////////////////////
547 {
548 Scoped0Inner s0i;
549 //Check construction with 0 user arguments
550 {
551 typedef ::allocator_argument_tester<NotUsesAllocator, 0> MarkType;
552 MarkType dummy;
553 dummy.~MarkType();
554 s0i.construct(p: &dummy);
555 BOOST_TEST(dummy.construction_type == NotUsesAllocator);
556 BOOST_TEST(dummy.value == 0 );
557 dummy.~MarkType();
558 }
559 {
560 typedef ::allocator_argument_tester<ConstructibleSuffix, 0> MarkType;
561 MarkType dummy;
562 dummy.~MarkType();
563 s0i.construct(p: &dummy);
564 BOOST_TEST(dummy.construction_type == ConstructibleSuffix);
565 BOOST_TEST(dummy.value == 0);
566 dummy.~MarkType();
567 }
568 {
569 typedef ::allocator_argument_tester<ConstructiblePrefix, 0> MarkType;
570 MarkType dummy;
571 dummy.~MarkType();
572 s0i.construct(p: &dummy);
573 BOOST_TEST(dummy.construction_type == ConstructiblePrefix);
574 BOOST_TEST(dummy.value == 0);
575 dummy.~MarkType();
576 }
577
578 //Check construction with 1 user arguments
579 {
580 typedef ::allocator_argument_tester<NotUsesAllocator, 0> MarkType;
581 MarkType dummy;
582 dummy.~MarkType();
583 s0i.construct(p: &dummy, args: 1);
584 BOOST_TEST(dummy.construction_type == NotUsesAllocator);
585 BOOST_TEST(dummy.value == 1);
586 dummy.~MarkType();
587 }
588 {
589 typedef ::allocator_argument_tester<ConstructibleSuffix, 0> MarkType;
590 MarkType dummy;
591 dummy.~MarkType();
592 s0i.construct(p: &dummy, args: 2);
593 BOOST_TEST(dummy.construction_type == ConstructibleSuffix);
594 BOOST_TEST(dummy.value == 2);
595 dummy.~MarkType();
596 }
597 {
598 typedef ::allocator_argument_tester<ConstructiblePrefix, 0> MarkType;
599 MarkType dummy;
600 dummy.~MarkType();
601 s0i.construct(p: &dummy, args: 3);
602 BOOST_TEST(dummy.construction_type == ConstructiblePrefix);
603 BOOST_TEST(dummy.value == 3);
604 dummy.~MarkType();
605 }
606 }
607 ////////////////////////////////////////////////////////////
608 //Then check scoped allocator with OuterAlloc and InnerAlloc.
609 //In this case InnerAlloc (propagation_test_allocator with tag 1) should be
610 //used to construct types.
611 ////////////////////////////////////////////////////////////
612 {
613 Scoped1Inner s1i;
614 //Check construction with 0 user arguments
615 {
616 typedef ::allocator_argument_tester<NotUsesAllocator, 1> MarkType;
617 MarkType dummy;
618 dummy.~MarkType();
619 s1i.construct(p: &dummy);
620 BOOST_TEST(dummy.construction_type == NotUsesAllocator);
621 BOOST_TEST(dummy.value == 0);
622 dummy.~MarkType();
623 }
624 {
625 typedef ::allocator_argument_tester<ConstructibleSuffix, 1> MarkType;
626 MarkType dummy;
627 dummy.~MarkType();
628 s1i.construct(p: &dummy);
629 BOOST_TEST(dummy.construction_type == ConstructibleSuffix);
630 BOOST_TEST(dummy.value == 0);
631 dummy.~MarkType();
632 }
633 {
634 typedef ::allocator_argument_tester<ConstructiblePrefix, 1> MarkType;
635 MarkType dummy;
636 dummy.~MarkType();
637 s1i.construct(p: &dummy);
638 BOOST_TEST(dummy.construction_type == ConstructiblePrefix);
639 BOOST_TEST(dummy.value == 0);
640 dummy.~MarkType();
641 }
642
643 //Check construction with 1 user arguments
644 {
645 typedef ::allocator_argument_tester<NotUsesAllocator, 1> MarkType;
646 MarkType dummy;
647 dummy.~MarkType();
648 s1i.construct(p: &dummy, args: 1);
649 BOOST_TEST(dummy.construction_type == NotUsesAllocator);
650 BOOST_TEST(dummy.value == 1);
651 dummy.~MarkType();
652 }
653 {
654 typedef ::allocator_argument_tester<ConstructibleSuffix, 1> MarkType;
655 MarkType dummy;
656 dummy.~MarkType();
657 s1i.construct(p: &dummy, args: 2);
658 BOOST_TEST(dummy.construction_type == ConstructibleSuffix);
659 BOOST_TEST(dummy.value == 2);
660 dummy.~MarkType();
661 }
662 {
663 typedef ::allocator_argument_tester<ConstructiblePrefix, 1> MarkType;
664 MarkType dummy;
665 dummy.~MarkType();
666 s1i.construct(p: &dummy, args: 3);
667 BOOST_TEST(dummy.construction_type == ConstructiblePrefix);
668 BOOST_TEST(dummy.value == 3);
669 dummy.~MarkType();
670 }
671 }
672
673 //////////////////////////////////////////////////////////////////////////////////
674 //Now test recursive OuterAllocator types (OuterAllocator is a scoped_allocator)
675 //////////////////////////////////////////////////////////////////////////////////
676
677 ////////////////////////////////////////////////////////////
678 //First check scoped allocator with just OuterAlloc.
679 //In this case OuterAlloc (propagation_test_allocator with tag 0) should be
680 //used to construct types.
681 ////////////////////////////////////////////////////////////
682 {
683 //Check outer_allocator_type is scoped
684 BOOST_CONTAINER_STATIC_ASSERT(( is_scoped_allocator
685 <ScopedScoped0Inner::outer_allocator_type>::value ));
686 BOOST_CONTAINER_STATIC_ASSERT(( dtl::is_same
687 < outermost_allocator<ScopedScoped0Inner>::type
688 , Outer10IdAlloc
689 >::value ));
690 BOOST_CONTAINER_STATIC_ASSERT(( dtl::is_same
691 < ScopedScoped0Inner::outer_allocator_type
692 , scoped_allocator_adaptor<Outer10IdAlloc>
693 >::value ));
694 BOOST_CONTAINER_STATIC_ASSERT(( dtl::is_same
695 < scoped_allocator_adaptor<Outer10IdAlloc>::outer_allocator_type
696 , Outer10IdAlloc
697 >::value ));
698 ScopedScoped0Inner ssro0i;
699 Outer10IdAlloc & val = outermost_allocator<ScopedScoped0Inner>::get(a&: ssro0i);
700 (void)val;
701 //Check construction with 0 user arguments
702 {
703 typedef ::allocator_argument_tester<NotUsesAllocator, 10> MarkType;
704 MarkType dummy;
705 dummy.~MarkType();
706 ssro0i.construct(p: &dummy);
707 BOOST_TEST(dummy.construction_type == NotUsesAllocator);
708 BOOST_TEST(dummy.value == 0);
709 dummy.~MarkType();
710 }
711 {
712 typedef ::allocator_argument_tester<ConstructibleSuffix, 10> MarkType;
713 MarkType dummy;
714 dummy.~MarkType();
715 ssro0i.construct(p: &dummy);
716 BOOST_TEST(dummy.construction_type == ConstructibleSuffix);
717 BOOST_TEST(dummy.value == 0);
718 dummy.~MarkType();
719 }
720 {
721 typedef ::allocator_argument_tester<ConstructiblePrefix, 10> MarkType;
722 MarkType dummy;
723 dummy.~MarkType();
724 ssro0i.construct(p: &dummy);
725 BOOST_TEST(dummy.construction_type == ConstructiblePrefix);
726 BOOST_TEST(dummy.value == 0);
727 dummy.~MarkType();
728 }
729
730 //Check construction with 1 user arguments
731 {
732 typedef ::allocator_argument_tester<NotUsesAllocator, 10> MarkType;
733 MarkType dummy;
734 dummy.~MarkType();
735 ssro0i.construct(p: &dummy, args: 1);
736 BOOST_TEST(dummy.construction_type == NotUsesAllocator);
737 BOOST_TEST(dummy.value == 1);
738 dummy.~MarkType();
739 }
740 {
741 typedef ::allocator_argument_tester<ConstructibleSuffix, 10> MarkType;
742 MarkType dummy;
743 dummy.~MarkType();
744 ssro0i.construct(p: &dummy, args: 2);
745 BOOST_TEST(dummy.construction_type == ConstructibleSuffix);
746 BOOST_TEST(dummy.value == 2);
747 dummy.~MarkType();
748 }
749 {
750 typedef ::allocator_argument_tester<ConstructiblePrefix, 10> MarkType;
751 MarkType dummy;
752 dummy.~MarkType();
753 ssro0i.construct(p: &dummy, args: 3);
754 BOOST_TEST(dummy.construction_type == ConstructiblePrefix);
755 BOOST_TEST(dummy.value == 3);
756 dummy.~MarkType();
757 }
758 }
759 ////////////////////////////////////////////////////////////
760 //Then check scoped allocator with OuterAlloc and InnerAlloc.
761 //In this case inner_allocator_type is not convertible to
762 //::allocator_argument_tester<XXX, 10> so uses_allocator
763 //should be false on all tests.
764 ////////////////////////////////////////////////////////////
765 {
766 //Check outer_allocator_type is scoped
767 BOOST_CONTAINER_STATIC_ASSERT(( is_scoped_allocator
768 <ScopedScoped1Inner::outer_allocator_type>::value ));
769 BOOST_CONTAINER_STATIC_ASSERT(( dtl::is_same
770 < outermost_allocator<ScopedScoped1Inner>::type
771 , Outer10IdAlloc
772 >::value ));
773 BOOST_CONTAINER_STATIC_ASSERT(( dtl::is_same
774 < ScopedScoped1Inner::outer_allocator_type
775 , scoped_allocator_adaptor<Outer10IdAlloc, Inner11IdAlloc1>
776 >::value ));
777 BOOST_CONTAINER_STATIC_ASSERT(( dtl::is_same
778 < scoped_allocator_adaptor<Outer10IdAlloc, Inner11IdAlloc1>::outer_allocator_type
779 , Outer10IdAlloc
780 >::value ));
781 BOOST_CONTAINER_STATIC_ASSERT(( !
782 uses_allocator
783 < ::allocator_argument_tester<ConstructibleSuffix, 10>
784 , ScopedScoped1Inner::inner_allocator_type::outer_allocator_type
785 >::value ));
786 ScopedScoped1Inner ssro1i;
787 Outer10IdAlloc & val = outermost_allocator<ScopedScoped1Inner>::get(a&: ssro1i);
788 (void)val;
789
790 //Check construction with 0 user arguments
791 {
792 typedef ::allocator_argument_tester<NotUsesAllocator, 10> MarkType;
793 MarkType dummy;
794 dummy.~MarkType();
795 ssro1i.construct(p: &dummy);
796 BOOST_TEST(dummy.construction_type == NotUsesAllocator);
797 BOOST_TEST(dummy.value == 0);
798 dummy.~MarkType();
799 }
800 {
801 typedef ::allocator_argument_tester<ConstructibleSuffix, 10> MarkType;
802 MarkType dummy;
803 dummy.~MarkType();
804 ssro1i.construct(p: &dummy);
805 BOOST_TEST(dummy.construction_type == NotUsesAllocator);
806 BOOST_TEST(dummy.value == 0);
807 dummy.~MarkType();
808 }
809 {
810 typedef ::allocator_argument_tester<ConstructiblePrefix, 10> MarkType;
811 MarkType dummy;
812 dummy.~MarkType();
813 ssro1i.construct(p: &dummy);
814 BOOST_TEST(dummy.construction_type == NotUsesAllocator);
815 BOOST_TEST(dummy.value == 0);
816 dummy.~MarkType();
817 }
818
819 //Check construction with 1 user arguments
820 {
821 typedef ::allocator_argument_tester<NotUsesAllocator, 10> MarkType;
822 MarkType dummy;
823 dummy.~MarkType();
824 ssro1i.construct(p: &dummy, args: 1);
825 BOOST_TEST(dummy.construction_type == NotUsesAllocator);
826 BOOST_TEST(dummy.value == 1);
827 dummy.~MarkType();
828 }
829 {
830 typedef ::allocator_argument_tester<ConstructibleSuffix, 10> MarkType;
831 MarkType dummy;
832 dummy.~MarkType();
833 ssro1i.construct(p: &dummy, args: 2);
834 BOOST_TEST(dummy.construction_type == NotUsesAllocator);
835 BOOST_TEST(dummy.value == 2);
836 dummy.~MarkType();
837 }
838 {
839 typedef ::allocator_argument_tester<ConstructiblePrefix, 10> MarkType;
840 MarkType dummy;
841 dummy.~MarkType();
842 ssro1i.construct(p: &dummy, args: 3);
843 BOOST_TEST(dummy.construction_type == NotUsesAllocator);
844 BOOST_TEST(dummy.value == 3);
845 dummy.~MarkType();
846 }
847 }
848
849 ////////////////////////////////////////////////////////////
850 //Now check propagation to pair
851 ////////////////////////////////////////////////////////////
852 //First check scoped allocator with just OuterAlloc.
853 //In this case OuterAlloc (propagation_test_allocator with tag 0) should be
854 //used to construct types.
855 ////////////////////////////////////////////////////////////
856 {
857 using dtl::pair;
858 typedef propagation_test_allocator< pair< tagged_integer<0>
859 , tagged_integer<0> >, 0> OuterPairAlloc;
860 //
861 typedef scoped_allocator_adaptor < OuterPairAlloc > ScopedPair0Inner;
862
863 ScopedPair0Inner s0i;
864 //Check construction with 0 user arguments
865 {
866 typedef ::allocator_argument_tester<NotUsesAllocator, 0> MarkType;
867 typedef pair<MarkType, MarkType> MarkTypePair;
868 MarkTypePair dummy;
869 dummy.~MarkTypePair();
870 s0i.construct(p: &dummy);
871 BOOST_TEST(dummy.first.construction_type == NotUsesAllocator);
872 BOOST_TEST(dummy.second.construction_type == NotUsesAllocator);
873 BOOST_TEST(dummy.first.value == 0);
874 BOOST_TEST(dummy.second.value == 0);
875 dummy.~MarkTypePair();
876 }
877 {
878 typedef ::allocator_argument_tester<ConstructibleSuffix, 0> MarkType;
879 typedef pair<MarkType, MarkType> MarkTypePair;
880 MarkTypePair dummy;
881 dummy.~MarkTypePair();
882 s0i.construct(p: &dummy);
883 BOOST_TEST(dummy.first.construction_type == ConstructibleSuffix);
884 BOOST_TEST(dummy.second.construction_type == ConstructibleSuffix);
885 BOOST_TEST(dummy.first.value == 0);
886 BOOST_TEST(dummy.second.value == 0);
887 dummy.~MarkTypePair();
888 }
889 {
890 typedef ::allocator_argument_tester<ConstructiblePrefix, 0> MarkType;
891 typedef pair<MarkType, MarkType> MarkTypePair;
892 MarkTypePair dummy;
893 dummy.~MarkTypePair();
894 s0i.construct(p: &dummy);
895 BOOST_TEST(dummy.first.construction_type == ConstructiblePrefix);
896 BOOST_TEST(dummy.second.construction_type == ConstructiblePrefix);
897 BOOST_TEST(dummy.first.value == 0);
898 BOOST_TEST(dummy.second.value == 0);
899 dummy.~MarkTypePair();
900 }
901 #if defined(BOOST_CONTAINER_PAIR_TEST_HAS_HEADER_TUPLE)
902 //Check construction with 0 user arguments and Std tuple
903 {
904 typedef ::allocator_argument_tester<NotUsesAllocator, 0> MarkType;
905 typedef pair<MarkType, MarkType> MarkTypePair;
906 MarkTypePair dummy;
907 dummy.~MarkTypePair();
908 s0i.construct(p: &dummy, args: piecewise_construct, args: std::tuple<>(), args: std::tuple<>());
909 BOOST_TEST(dummy.first.construction_type == NotUsesAllocator);
910 BOOST_TEST(dummy.second.construction_type == NotUsesAllocator);
911 BOOST_TEST(dummy.first.value == 0);
912 BOOST_TEST(dummy.second.value == 0);
913 dummy.~MarkTypePair();
914 }
915 {
916 typedef ::allocator_argument_tester<ConstructibleSuffix, 0> MarkType;
917 typedef pair<MarkType, MarkType> MarkTypePair;
918 MarkTypePair dummy;
919 dummy.~MarkTypePair();
920 s0i.construct(p: &dummy, args: piecewise_construct, args: std::tuple<>(), args: std::tuple<>());
921 BOOST_TEST(dummy.first.construction_type == ConstructibleSuffix);
922 BOOST_TEST(dummy.second.construction_type == ConstructibleSuffix);
923 BOOST_TEST(dummy.first.value == 0);
924 BOOST_TEST(dummy.second.value == 0);
925 dummy.~MarkTypePair();
926 }
927 {
928 typedef ::allocator_argument_tester<ConstructiblePrefix, 0> MarkType;
929 typedef pair<MarkType, MarkType> MarkTypePair;
930 MarkTypePair dummy;
931 dummy.~MarkTypePair();
932 s0i.construct(p: &dummy, args: piecewise_construct, args: std::tuple<>(), args: std::tuple<>());
933 BOOST_TEST(dummy.first.construction_type == ConstructiblePrefix);
934 BOOST_TEST(dummy.second.construction_type == ConstructiblePrefix);
935 BOOST_TEST(dummy.first.value == 0);
936 BOOST_TEST(dummy.second.value == 0);
937 dummy.~MarkTypePair();
938 }
939 {
940 typedef ::allocator_argument_tester<NotUsesAllocator, 0> MarkType;
941 typedef pair<MarkType, MarkType> MarkTypePair;
942 MarkTypePair dummy;
943 dummy.~MarkTypePair();
944 s0i.construct(p: &dummy, args: piecewise_construct, args: std::tuple<>(), args: std::tuple<>());
945 BOOST_TEST(dummy.first.construction_type == NotUsesAllocator);
946 BOOST_TEST(dummy.second.construction_type == NotUsesAllocator);
947 BOOST_TEST(dummy.first.value == 0);
948 BOOST_TEST(dummy.second.value == 0);
949 dummy.~MarkTypePair();
950 }
951 {
952 typedef ::allocator_argument_tester<ConstructibleSuffix, 0> MarkType;
953 typedef pair<MarkType, MarkType> MarkTypePair;
954 MarkTypePair dummy;
955 dummy.~MarkTypePair();
956 s0i.construct(p: &dummy, args: piecewise_construct, args: std::tuple<>(), args: std::tuple<>());
957 BOOST_TEST(dummy.first.construction_type == ConstructibleSuffix);
958 BOOST_TEST(dummy.second.construction_type == ConstructibleSuffix);
959 BOOST_TEST(dummy.first.value == 0);
960 BOOST_TEST(dummy.second.value == 0);
961 dummy.~MarkTypePair();
962 }
963 {
964 typedef ::allocator_argument_tester<ConstructiblePrefix, 0> MarkType;
965 typedef pair<MarkType, MarkType> MarkTypePair;
966 MarkTypePair dummy;
967 dummy.~MarkTypePair();
968 s0i.construct(p: &dummy, args: piecewise_construct, args: std::tuple<>(), args: std::tuple<>());
969 BOOST_TEST(dummy.first.construction_type == ConstructiblePrefix);
970 BOOST_TEST(dummy.second.construction_type == ConstructiblePrefix);
971 BOOST_TEST(dummy.first.value == 0);
972 BOOST_TEST(dummy.second.value == 0);
973 dummy.~MarkTypePair();
974 }
975 #endif //BOOST_CONTAINER_PAIR_TEST_HAS_HEADER_TUPLE
976 //Check construction with 1 user arguments for each pair
977 {
978 typedef ::allocator_argument_tester<NotUsesAllocator, 0> MarkType;
979 typedef pair<MarkType, MarkType> MarkTypePair;
980 MarkTypePair dummy;
981 dummy.~MarkTypePair();
982 s0i.construct(p: &dummy, args: 1, args: 1);
983 BOOST_TEST(dummy.first.construction_type == NotUsesAllocator);
984 BOOST_TEST(dummy.second.construction_type == NotUsesAllocator);
985 BOOST_TEST(dummy.first.value == 1);
986 BOOST_TEST(dummy.second.value == 1);
987 dummy.~MarkTypePair();
988 }
989 {
990 typedef ::allocator_argument_tester<ConstructibleSuffix, 0> MarkType;
991 typedef pair<MarkType, MarkType> MarkTypePair;
992 MarkTypePair dummy;
993 dummy.~MarkTypePair();
994 s0i.construct(p: &dummy, args: 1, args: 1);
995 BOOST_TEST(dummy.first.construction_type == ConstructibleSuffix);
996 BOOST_TEST(dummy.second.construction_type == ConstructibleSuffix);
997 BOOST_TEST(dummy.first.value == 1);
998 BOOST_TEST(dummy.second.value == 1);
999 dummy.~MarkTypePair();
1000 }
1001 {
1002 typedef ::allocator_argument_tester<ConstructiblePrefix, 0> MarkType;
1003 typedef pair<MarkType, MarkType> MarkTypePair;
1004 MarkTypePair dummy;
1005 dummy.~MarkTypePair();
1006 s0i.construct(p: &dummy, args: 2, args: 2);
1007 BOOST_TEST(dummy.first.construction_type == ConstructiblePrefix);
1008 BOOST_TEST(dummy.second.construction_type == ConstructiblePrefix);
1009 BOOST_TEST(dummy.first.value == 2);
1010 BOOST_TEST(dummy.second.value == 2);
1011 dummy.~MarkTypePair();
1012 }
1013 //Check construction with 1 user arguments for each pair and Boost tuple
1014 {
1015 typedef ::allocator_argument_tester<NotUsesAllocator, 0> MarkType;
1016 typedef pair<MarkType, MarkType> MarkTypePair;
1017 MarkTypePair dummy;
1018 dummy.~MarkTypePair();
1019 s0i.construct(p: &dummy, args: piecewise_construct, args: boost::tuple<int>(1), args: boost::tuple<int>(1));
1020 BOOST_TEST(dummy.first.construction_type == NotUsesAllocator);
1021 BOOST_TEST(dummy.second.construction_type == NotUsesAllocator);
1022 BOOST_TEST(dummy.first.value == 1);
1023 BOOST_TEST(dummy.second.value == 1);
1024 dummy.~MarkTypePair();
1025 }
1026 {
1027 typedef ::allocator_argument_tester<ConstructibleSuffix, 0> MarkType;
1028 typedef pair<MarkType, MarkType> MarkTypePair;
1029 MarkTypePair dummy;
1030 dummy.~MarkTypePair();
1031 s0i.construct(p: &dummy, args: piecewise_construct, args: boost::tuple<int>(1), args: boost::tuple<int>(1));
1032 BOOST_TEST(dummy.first.construction_type == ConstructibleSuffix);
1033 BOOST_TEST(dummy.second.construction_type == ConstructibleSuffix);
1034 BOOST_TEST(dummy.first.value == 1);
1035 BOOST_TEST(dummy.second.value == 1);
1036 dummy.~MarkTypePair();
1037 }
1038 {
1039 typedef ::allocator_argument_tester<ConstructiblePrefix, 0> MarkType;
1040 typedef pair<MarkType, MarkType> MarkTypePair;
1041 MarkTypePair dummy;
1042 dummy.~MarkTypePair();
1043 s0i.construct(p: &dummy, args: piecewise_construct, args: boost::tuple<int>(2), args: boost::tuple<int>(2));
1044 BOOST_TEST(dummy.first.construction_type == ConstructiblePrefix);
1045 BOOST_TEST(dummy.second.construction_type == ConstructiblePrefix);
1046 BOOST_TEST(dummy.first.value == 2);
1047 BOOST_TEST(dummy.second.value == 2);
1048 dummy.~MarkTypePair();
1049 }
1050 #if defined(BOOST_CONTAINER_PAIR_TEST_HAS_HEADER_TUPLE)
1051 //Check construction with 1 user arguments for each pair and Boost tuple
1052 {
1053 typedef ::allocator_argument_tester<NotUsesAllocator, 0> MarkType;
1054 typedef pair<MarkType, MarkType> MarkTypePair;
1055 MarkTypePair dummy;
1056 dummy.~MarkTypePair();
1057 s0i.construct(p: &dummy, args: piecewise_construct, args: std::tuple<int>(1), args: std::tuple<int>(1));
1058 BOOST_TEST(dummy.first.construction_type == NotUsesAllocator);
1059 BOOST_TEST(dummy.second.construction_type == NotUsesAllocator);
1060 BOOST_TEST(dummy.first.value == 1);
1061 BOOST_TEST(dummy.second.value == 1);
1062 dummy.~MarkTypePair();
1063 }
1064 {
1065 typedef ::allocator_argument_tester<ConstructibleSuffix, 0> MarkType;
1066 typedef pair<MarkType, MarkType> MarkTypePair;
1067 MarkTypePair dummy;
1068 dummy.~MarkTypePair();
1069 s0i.construct(p: &dummy, args: piecewise_construct, args: std::tuple<int>(1), args: std::tuple<int>(1));
1070 BOOST_TEST(dummy.first.construction_type == ConstructibleSuffix);
1071 BOOST_TEST(dummy.second.construction_type == ConstructibleSuffix);
1072 BOOST_TEST(dummy.first.value == 1);
1073 BOOST_TEST(dummy.second.value == 1);
1074 dummy.~MarkTypePair();
1075 }
1076 {
1077 typedef ::allocator_argument_tester<ConstructiblePrefix, 0> MarkType;
1078 typedef pair<MarkType, MarkType> MarkTypePair;
1079 MarkTypePair dummy;
1080 dummy.~MarkTypePair();
1081 s0i.construct(p: &dummy, args: piecewise_construct, args: std::tuple<int>(2), args: std::tuple<int>(2));
1082 BOOST_TEST(dummy.first.construction_type == ConstructiblePrefix);
1083 BOOST_TEST(dummy.second.construction_type == ConstructiblePrefix);
1084 BOOST_TEST(dummy.first.value == 2);
1085 BOOST_TEST(dummy.second.value == 2);
1086 dummy.~MarkTypePair();
1087 }
1088 #endif //BOOST_CONTAINER_PAIR_TEST_HAS_HEADER_TUPLE
1089 //Check construction with pair copy construction
1090 {
1091 typedef ::allocator_argument_tester<NotUsesAllocator, 0> MarkType;
1092 typedef pair<MarkType, MarkType> MarkTypePair;
1093 MarkTypePair dummy, dummy2;
1094 dummy.~MarkTypePair();
1095 s0i.construct(p: &dummy, args&: dummy2);
1096 BOOST_TEST(dummy.first.construction_type == NotUsesAllocator);
1097 BOOST_TEST(dummy.second.construction_type == NotUsesAllocator);
1098 BOOST_TEST(dummy.first.value == 0);
1099 BOOST_TEST(dummy.second.value == 0);
1100 dummy.~MarkTypePair();
1101 }
1102 {
1103 typedef ::allocator_argument_tester<ConstructibleSuffix, 0> MarkType;
1104 typedef pair<MarkType, MarkType> MarkTypePair;
1105 MarkTypePair dummy, dummy2(1, 1);
1106 dummy.~MarkTypePair();
1107 s0i.construct(p: &dummy, args&: dummy2);
1108 BOOST_TEST(dummy.first.construction_type == ConstructibleSuffix);
1109 BOOST_TEST(dummy.second.construction_type == ConstructibleSuffix);
1110 BOOST_TEST(dummy.first.value == 1);
1111 BOOST_TEST(dummy.second.value == 1);
1112 dummy.~MarkTypePair();
1113 }
1114 {
1115 typedef ::allocator_argument_tester<ConstructiblePrefix, 0> MarkType;
1116 typedef pair<MarkType, MarkType> MarkTypePair;
1117 MarkTypePair dummy, dummy2(2, 2);
1118 dummy.~MarkTypePair();
1119 s0i.construct(p: &dummy, args&: dummy2);
1120 BOOST_TEST(dummy.first.construction_type == ConstructiblePrefix);
1121 BOOST_TEST(dummy.second.construction_type == ConstructiblePrefix);
1122 BOOST_TEST(dummy.first.value == 2);
1123 BOOST_TEST(dummy.second.value == 2);
1124 dummy.~MarkTypePair();
1125 }
1126 //Check construction with pair move construction
1127 {
1128 typedef ::allocator_argument_tester<NotUsesAllocator, 0> MarkType;
1129 typedef pair<MarkType, MarkType> MarkTypePair;
1130 MarkTypePair dummy, dummy2(3, 3);
1131 dummy2.first.construction_type = dummy2.second.construction_type = ConstructibleSuffix;
1132 dummy.~MarkTypePair();
1133 s0i.construct(p: &dummy, args: ::boost::move(t&: dummy2));
1134 BOOST_TEST(dummy.first.construction_type == NotUsesAllocator);
1135 BOOST_TEST(dummy.second.construction_type == NotUsesAllocator);
1136 BOOST_TEST(dummy.first.value == 3);
1137 BOOST_TEST(dummy.second.value == 3);
1138 BOOST_TEST(dummy2.first.construction_type == NotUsesAllocator);
1139 BOOST_TEST(dummy2.second.construction_type == NotUsesAllocator);
1140 BOOST_TEST(dummy2.first.value == 0);
1141 BOOST_TEST(dummy2.second.value == 0);
1142 dummy.~MarkTypePair();
1143 }
1144 {
1145 typedef ::allocator_argument_tester<ConstructibleSuffix, 0> MarkType;
1146 typedef pair<MarkType, MarkType> MarkTypePair;
1147 MarkTypePair dummy, dummy2(1, 1);
1148 dummy.~MarkTypePair();
1149 s0i.construct(p: &dummy, args: ::boost::move(t&: dummy2));
1150 BOOST_TEST(dummy.first.construction_type == ConstructibleSuffix);
1151 BOOST_TEST(dummy.second.construction_type == ConstructibleSuffix);
1152 BOOST_TEST(dummy.first.value == 1);
1153 BOOST_TEST(dummy.second.value == 1);
1154 BOOST_TEST(dummy2.first.construction_type == ConstructibleSuffix);
1155 BOOST_TEST(dummy2.second.construction_type == ConstructibleSuffix);
1156 BOOST_TEST(dummy2.first.value == 0);
1157 BOOST_TEST(dummy2.second.value == 0);
1158 dummy.~MarkTypePair();
1159 }
1160 {
1161 typedef ::allocator_argument_tester<ConstructiblePrefix, 0> MarkType;
1162 typedef pair<MarkType, MarkType> MarkTypePair;
1163 MarkTypePair dummy, dummy2(2, 2);
1164 dummy.~MarkTypePair();
1165 s0i.construct(p: &dummy, args: ::boost::move(t&: dummy2));
1166 BOOST_TEST(dummy.first.construction_type == ConstructiblePrefix);
1167 BOOST_TEST(dummy.second.construction_type == ConstructiblePrefix);
1168 BOOST_TEST(dummy.first.value == 2);
1169 BOOST_TEST(dummy.second.value == 2);
1170 BOOST_TEST(dummy2.first.construction_type == ConstructiblePrefix);
1171 BOOST_TEST(dummy2.second.construction_type == ConstructiblePrefix);
1172 BOOST_TEST(dummy2.first.value == 0);
1173 BOOST_TEST(dummy2.second.value == 0);
1174 dummy.~MarkTypePair();
1175 }
1176 //Check construction with related pair copy construction
1177 {
1178 typedef ::allocator_argument_tester<NotUsesAllocator, 0> MarkType;
1179 typedef pair<MarkType, MarkType> MarkTypePair;
1180 MarkTypePair dummy;
1181 pair<int, int> dummy2;
1182 dummy.~MarkTypePair();
1183 s0i.construct(p: &dummy, args&: dummy2);
1184 BOOST_TEST(dummy.first.construction_type == NotUsesAllocator);
1185 BOOST_TEST(dummy.second.construction_type == NotUsesAllocator);
1186 BOOST_TEST(dummy.first.value == 0);
1187 BOOST_TEST(dummy.second.value == 0);
1188 dummy.~MarkTypePair();
1189 }
1190 {
1191 typedef ::allocator_argument_tester<ConstructibleSuffix, 0> MarkType;
1192 typedef pair<MarkType, MarkType> MarkTypePair;
1193 MarkTypePair dummy;
1194 pair<int, int> dummy2(1, 1);
1195 dummy.~MarkTypePair();
1196 s0i.construct(p: &dummy, args&: dummy2);
1197 BOOST_TEST(dummy.first.construction_type == ConstructibleSuffix);
1198 BOOST_TEST(dummy.second.construction_type == ConstructibleSuffix);
1199 BOOST_TEST(dummy.first.value == 1);
1200 BOOST_TEST(dummy.second.value == 1);
1201 dummy.~MarkTypePair();
1202 }
1203 {
1204 typedef ::allocator_argument_tester<ConstructiblePrefix, 0> MarkType;
1205 typedef pair<MarkType, MarkType> MarkTypePair;
1206 MarkTypePair dummy;
1207 pair<int, int> dummy2(2, 2);
1208 dummy.~MarkTypePair();
1209 s0i.construct(p: &dummy, args&: dummy2);
1210 BOOST_TEST(dummy.first.construction_type == ConstructiblePrefix);
1211 BOOST_TEST(dummy.second.construction_type == ConstructiblePrefix);
1212 BOOST_TEST(dummy.first.value == 2);
1213 BOOST_TEST(dummy.second.value == 2);
1214 dummy.~MarkTypePair();
1215 }
1216 //Check construction with related pair move construction
1217 {
1218 typedef ::allocator_argument_tester<NotUsesAllocator, 0> MarkType;
1219 typedef pair<MarkType, MarkType> MarkTypePair;
1220 MarkTypePair dummy;
1221 pair<int, int> dummy2(3, 3);
1222 dummy.~MarkTypePair();
1223 s0i.construct(p: &dummy, args: ::boost::move(t&: dummy2));
1224 BOOST_TEST(dummy.first.construction_type == NotUsesAllocator);
1225 BOOST_TEST(dummy.second.construction_type == NotUsesAllocator);
1226 BOOST_TEST(dummy.first.value == 3);
1227 BOOST_TEST(dummy.second.value == 3);
1228 dummy.~MarkTypePair();
1229 }
1230 {
1231 typedef ::allocator_argument_tester<ConstructibleSuffix, 0> MarkType;
1232 typedef pair<MarkType, MarkType> MarkTypePair;
1233 MarkTypePair dummy;
1234 pair<int, int> dummy2(1, 1);
1235 dummy.~MarkTypePair();
1236 s0i.construct(p: &dummy, args: ::boost::move(t&: dummy2));
1237 BOOST_TEST(dummy.first.construction_type == ConstructibleSuffix);
1238 BOOST_TEST(dummy.second.construction_type == ConstructibleSuffix);
1239 BOOST_TEST(dummy.first.value == 1);
1240 BOOST_TEST(dummy.second.value == 1);
1241 dummy.~MarkTypePair();
1242 }
1243 {
1244 typedef ::allocator_argument_tester<ConstructiblePrefix, 0> MarkType;
1245 typedef pair<MarkType, MarkType> MarkTypePair;
1246 MarkTypePair dummy;
1247 pair<int, int> dummy2(2, 2);
1248 dummy.~MarkTypePair();
1249 s0i.construct(p: &dummy, args: ::boost::move(t&: dummy2));
1250 BOOST_TEST(dummy.first.construction_type == ConstructiblePrefix);
1251 BOOST_TEST(dummy.second.construction_type == ConstructiblePrefix);
1252 BOOST_TEST(dummy.first.value == 2);
1253 BOOST_TEST(dummy.second.value == 2);
1254 dummy.~MarkTypePair();
1255 }
1256 //Check construction with 0/1 arguments for each pair and Boost tuple
1257 {
1258 typedef ::allocator_argument_tester<NotUsesAllocator, 0> MarkType;
1259 typedef pair<MarkType, MarkType> MarkTypePair;
1260 MarkTypePair dummy;
1261 dummy.~MarkTypePair();
1262 s0i.construct(p: &dummy, args: piecewise_construct, args: boost::tuple<>(), args: boost::tuple<int>(1));
1263 BOOST_TEST(dummy.first.construction_type == NotUsesAllocator);
1264 BOOST_TEST(dummy.second.construction_type == NotUsesAllocator);
1265 BOOST_TEST(dummy.first.value == 0);
1266 BOOST_TEST(dummy.second.value == 1);
1267 dummy.~MarkTypePair();
1268 }
1269 {
1270 typedef ::allocator_argument_tester<ConstructibleSuffix, 0> MarkType;
1271 typedef pair<MarkType, MarkType> MarkTypePair;
1272 MarkTypePair dummy;
1273 dummy.~MarkTypePair();
1274 s0i.construct(p: &dummy, args: piecewise_construct, args: boost::tuple<int>(1), args: boost::tuple<>());
1275 BOOST_TEST(dummy.first.construction_type == ConstructibleSuffix);
1276 BOOST_TEST(dummy.second.construction_type == ConstructibleSuffix);
1277 BOOST_TEST(dummy.first.value == 1);
1278 BOOST_TEST(dummy.second.value == 0);
1279 dummy.~MarkTypePair();
1280 }
1281 {
1282 typedef ::allocator_argument_tester<ConstructiblePrefix, 0> MarkType;
1283 typedef pair<MarkType, MarkType> MarkTypePair;
1284 MarkTypePair dummy;
1285 dummy.~MarkTypePair();
1286 s0i.construct(p: &dummy, args: piecewise_construct, args: boost::tuple<>(), args: boost::tuple<int>(2));
1287 BOOST_TEST(dummy.first.construction_type == ConstructiblePrefix);
1288 BOOST_TEST(dummy.second.construction_type == ConstructiblePrefix);
1289 BOOST_TEST(dummy.first.value == 0);
1290 BOOST_TEST(dummy.second.value == 2);
1291 dummy.~MarkTypePair();
1292 }
1293 #if defined(BOOST_CONTAINER_PAIR_TEST_HAS_HEADER_TUPLE)
1294 //Check construction with 0/1 arguments for each pair and Boost tuple
1295 {
1296 typedef ::allocator_argument_tester<NotUsesAllocator, 0> MarkType;
1297 typedef pair<MarkType, MarkType> MarkTypePair;
1298 MarkTypePair dummy;
1299 dummy.~MarkTypePair();
1300 s0i.construct(p: &dummy, args: piecewise_construct, args: std::tuple<>(), args: std::tuple<int>(1));
1301 BOOST_TEST(dummy.first.construction_type == NotUsesAllocator);
1302 BOOST_TEST(dummy.second.construction_type == NotUsesAllocator);
1303 BOOST_TEST(dummy.first.value == 0);
1304 BOOST_TEST(dummy.second.value == 1);
1305 dummy.~MarkTypePair();
1306 }
1307 {
1308 typedef ::allocator_argument_tester<ConstructibleSuffix, 0> MarkType;
1309 typedef pair<MarkType, MarkType> MarkTypePair;
1310 MarkTypePair dummy;
1311 dummy.~MarkTypePair();
1312 s0i.construct(p: &dummy, args: piecewise_construct, args: std::tuple<int>(1), args: std::tuple<>());
1313 BOOST_TEST(dummy.first.construction_type == ConstructibleSuffix);
1314 BOOST_TEST(dummy.second.construction_type == ConstructibleSuffix);
1315 BOOST_TEST(dummy.first.value == 1);
1316 BOOST_TEST(dummy.second.value == 0);
1317 dummy.~MarkTypePair();
1318 }
1319 {
1320 typedef ::allocator_argument_tester<ConstructiblePrefix, 0> MarkType;
1321 typedef pair<MarkType, MarkType> MarkTypePair;
1322 MarkTypePair dummy;
1323 dummy.~MarkTypePair();
1324 s0i.construct(p: &dummy, args: piecewise_construct, args: std::tuple<>(), args: std::tuple<int>(2));
1325 BOOST_TEST(dummy.first.construction_type == ConstructiblePrefix);
1326 BOOST_TEST(dummy.second.construction_type == ConstructiblePrefix);
1327 BOOST_TEST(dummy.first.value == 0);
1328 BOOST_TEST(dummy.second.value == 2);
1329 dummy.~MarkTypePair();
1330 }
1331 #endif //BOOST_CONTAINER_PAIR_TEST_HAS_HEADER_TUPLE
1332
1333 //Check construction with try_emplace_t 0/1 arguments for each pair
1334 {
1335 typedef ::allocator_argument_tester<NotUsesAllocator, 0> MarkType;
1336 typedef pair<MarkType, MarkType> MarkTypePair;
1337 MarkTypePair dummy;
1338 dummy.~MarkTypePair();
1339 s0i.construct(p: &dummy, args: try_emplace_t(), args: 5, args: 1);
1340 BOOST_TEST(dummy.first.construction_type == NotUsesAllocator);
1341 BOOST_TEST(dummy.second.construction_type == NotUsesAllocator);
1342 BOOST_TEST(dummy.first.value == 5);
1343 BOOST_TEST(dummy.second.value == 1);
1344 dummy.~MarkTypePair();
1345 }
1346 {
1347 typedef ::allocator_argument_tester<ConstructibleSuffix, 0> MarkType;
1348 typedef pair<MarkType, MarkType> MarkTypePair;
1349 MarkTypePair dummy;
1350 dummy.~MarkTypePair();
1351 s0i.construct(p: &dummy, args: try_emplace_t(), args: 6);
1352 BOOST_TEST(dummy.first.construction_type == ConstructibleSuffix);
1353 BOOST_TEST(dummy.second.construction_type == ConstructibleSuffix);
1354 BOOST_TEST(dummy.first.value == 6);
1355 BOOST_TEST(dummy.second.value == 0);
1356 dummy.~MarkTypePair();
1357 }
1358 {
1359 typedef ::allocator_argument_tester<ConstructiblePrefix, 0> MarkType;
1360 typedef pair<MarkType, MarkType> MarkTypePair;
1361 MarkTypePair dummy;
1362 dummy.~MarkTypePair();
1363 s0i.construct(p: &dummy, args: try_emplace_t(), args: 7, args: 2);
1364 BOOST_TEST(dummy.first.construction_type == ConstructiblePrefix);
1365 BOOST_TEST(dummy.second.construction_type == ConstructiblePrefix);
1366 BOOST_TEST(dummy.first.value == 7);
1367 BOOST_TEST(dummy.second.value == 2);
1368 dummy.~MarkTypePair();
1369 }
1370 }
1371 }
1372
1373 return ::boost::report_errors();
1374}
1375

source code of boost/libs/container/test/scoped_allocator_adaptor_test.cpp