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