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