1 // Boost.Container static_vector
4 // Copyright (c) 2012-2013 Adam Wulkiewicz, Lodz, Poland.
5 // Copyright (c) 2012-2013 Andrew Hundt.
7 // Use, modification and distribution is subject to the Boost Software License,
8 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
9 // http://www.boost.org/LICENSE_1_0.txt)
10 #include <boost/core/lightweight_test.hpp>
11 #include <boost/core/no_exceptions_support.hpp>
12 #include <boost/container/vector.hpp>
13 #include <boost/container/list.hpp>
14 #include <boost/container/detail/iterator.hpp>
15 #include "../../intrusive/test/iterator_test.hpp"
17 #include "static_vector_test.hpp"
20 template <typename T
, size_t N
>
23 static_vector
<T
, N
> s
;
24 BOOST_STATIC_ASSERT((static_vector
<T
, N
>::static_capacity
) == N
);
25 BOOST_TEST_EQ(s
.size() , 0u);
26 BOOST_TEST(s
.capacity() == N
);
27 BOOST_TEST(s
.max_size() == N
);
28 BOOST_TEST_THROWS( s
.at(0u), std::out_of_range
);
31 template <typename T
, size_t N
>
32 void test_ctor_nc(size_t n
)
34 static_vector
<T
, N
> s(n
);
35 BOOST_STATIC_ASSERT((static_vector
<T
, N
>::static_capacity
) == N
);
36 BOOST_TEST(s
.size() == n
);
37 BOOST_TEST(s
.capacity() == N
);
38 BOOST_TEST(s
.max_size() == N
);
39 BOOST_TEST_THROWS( s
.at(n
), std::out_of_range
);
43 BOOST_TEST(T(10) == s
[0]);
44 BOOST_TEST(T(10) == s
.at(0));
46 BOOST_TEST(T(20) == s
[1]);
47 BOOST_TEST(T(20) == s
.at(1));
51 template <typename T
, size_t N
>
52 void test_ctor_nd(size_t n
, T
const& v
)
54 static_vector
<T
, N
> s(n
, v
);
55 BOOST_STATIC_ASSERT((static_vector
<T
, N
>::static_capacity
) == N
);
56 BOOST_TEST(s
.size() == n
);
57 BOOST_TEST(s
.capacity() == N
);
58 BOOST_TEST_THROWS( s
.at(n
), std::out_of_range
);
61 BOOST_TEST(v
== s
[0]);
62 BOOST_TEST(v
== s
.at(0));
63 BOOST_TEST(v
== s
[1]);
64 BOOST_TEST(v
== s
.at(1));
66 BOOST_TEST(T(10) == s
[0]);
67 BOOST_TEST(T(10) == s
.at(0));
69 BOOST_TEST(T(20) == s
[1]);
70 BOOST_TEST(T(20) == s
.at(1));
74 void test_support_for_initializer_list()
76 #if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST)
78 typedef static_vector
<int, 2> sv_cap_2
;
79 sv_cap_2 sv
= {10, 8};
80 BOOST_TEST(10 == sv
[0]);
81 BOOST_TEST(8 == sv
[1]);
83 BOOST_TEST_THROWS(sv_cap_2({1, 1, 1}), std::bad_alloc
);
87 static_vector
<int, 2> sv
;
89 BOOST_TEST(1 == sv
[0]);
90 BOOST_TEST(2 == sv
[1]);
92 BOOST_TEST_THROWS(sv
.assign({1, 2, 3}), std::bad_alloc
);
94 static_vector
<int, 3> greaterThanSv
= {1, 2, 3};
95 BOOST_TEST_THROWS(sv
= greaterThanSv
, std::bad_alloc
);
99 static_vector
<int, 2> sv
;
100 sv
.insert(sv
.begin(), {99, 95});
101 BOOST_TEST(99 == sv
[0]);
102 BOOST_TEST(95 == sv
[1]);
104 BOOST_TEST_THROWS(sv
.insert(sv
.begin(), {101, 102, 103}), std::bad_alloc
);
109 template <typename T
, size_t N
>
110 void test_resize_nc(size_t n
)
112 static_vector
<T
, N
> s
;
115 BOOST_TEST(s
.size() == n
);
116 BOOST_TEST(s
.capacity() == N
);
117 BOOST_TEST_THROWS( s
.at(n
), std::out_of_range
);
121 BOOST_TEST(T(10) == s
[0]);
122 BOOST_TEST(T(10) == s
.at(0));
124 BOOST_TEST(T(20) == s
[1]);
125 BOOST_TEST(T(20) == s
.at(1));
129 template <typename T
, size_t N
>
130 void test_resize_nd(size_t n
, T
const& v
)
132 static_vector
<T
, N
> s
;
135 BOOST_TEST(s
.size() == n
);
136 BOOST_TEST(s
.capacity() == N
);
137 BOOST_TEST_THROWS( s
.at(n
), std::out_of_range
);
140 BOOST_TEST(v
== s
[0]);
141 BOOST_TEST(v
== s
.at(0));
142 BOOST_TEST(v
== s
[1]);
143 BOOST_TEST(v
== s
.at(1));
145 BOOST_TEST(T(10) == s
[0]);
146 BOOST_TEST(T(10) == s
.at(0));
148 BOOST_TEST(T(20) == s
[1]);
149 BOOST_TEST(T(20) == s
.at(1));
153 template <typename T
, size_t N
>
154 void test_push_back_nd()
156 static_vector
<T
, N
> s
;
158 BOOST_TEST(s
.size() == 0);
159 BOOST_TEST_THROWS( s
.at(0), std::out_of_range
);
161 for ( size_t i
= 0 ; i
< N
; ++i
)
163 T
t(static_cast<int>(i
));
165 BOOST_TEST(s
.size() == i
+ 1);
166 BOOST_TEST_THROWS( s
.at(i
+ 1), std::out_of_range
);
167 BOOST_TEST(T((int)i
) == s
.at(i
));
168 BOOST_TEST(T((int)i
) == s
[i
]);
169 BOOST_TEST(T((int)i
) == s
.back());
170 BOOST_TEST(T(0) == s
.front());
171 BOOST_TEST(T((int)i
) == *(s
.data() + i
));
175 template <typename T
, size_t N
>
176 void test_pop_back_nd()
178 static_vector
<T
, N
> s
;
180 for ( size_t i
= 0 ; i
< N
; ++i
)
186 for ( size_t i
= N
; i
> 1 ; --i
)
189 BOOST_TEST(s
.size() == i
- 1);
190 BOOST_TEST_THROWS( s
.at(i
- 1), std::out_of_range
);
191 BOOST_TEST(T((int)i
- 2) == s
.at(i
- 2));
192 BOOST_TEST(T((int)i
- 2) == s
[i
- 2]);
193 BOOST_TEST(T((int)i
- 2) == s
.back());
194 BOOST_TEST(T(0) == s
.front());
198 template <typename It1
, typename It2
>
199 void test_compare_ranges(It1 first1
, It1 last1
, It2 first2
, It2 last2
)
201 BOOST_TEST(boost::container::iterator_distance(first1
, last1
) == boost::container::iterator_distance(first2
, last2
));
202 for ( ; first1
!= last1
&& first2
!= last2
; ++first1
, ++first2
)
203 BOOST_TEST(*first1
== *first2
);
206 template <typename T
, size_t N
, typename C
>
207 void test_copy_and_assign(C
const& c
)
210 static_vector
<T
, N
> s(c
.begin(), c
.end());
211 BOOST_TEST(s
.size() == c
.size());
212 test_compare_ranges(s
.begin(), s
.end(), c
.begin(), c
.end());
215 static_vector
<T
, N
> s
;
216 BOOST_TEST(0 == s
.size());
217 s
.assign(c
.begin(), c
.end());
218 BOOST_TEST(s
.size() == c
.size());
219 test_compare_ranges(s
.begin(), s
.end(), c
.begin(), c
.end());
223 template <typename T
, size_t N
>
224 void test_copy_and_assign_nd(T
const& val
)
226 static_vector
<T
, N
> s
;
230 for ( size_t i
= 0 ; i
< N
; ++i
)
239 static_vector
<T
, N
> s1(s
);
240 BOOST_TEST(s
.size() == s1
.size());
241 test_compare_ranges(s
.begin(), s
.end(), s1
.begin(), s1
.end());
245 static_vector
<T
, N
> s1
;
246 BOOST_TEST(0 == s1
.size());
248 BOOST_TEST(s
.size() == s1
.size());
249 test_compare_ranges(s
.begin(), s
.end(), s1
.begin(), s1
.end());
252 // ctor(Iter, Iter) and assign(Iter, Iter)
253 test_copy_and_assign
<T
, N
>(s
);
254 test_copy_and_assign
<T
, N
>(v
);
255 test_copy_and_assign
<T
, N
>(l
);
259 static_vector
<T
, N
> s1(s
);
260 test_compare_ranges(s
.begin(), s
.end(), s1
.begin(), s1
.end());
263 test_compare_ranges(a
.begin(), a
.end(), s1
.begin(), s1
.end());
267 template <typename T
, size_t N
>
268 void test_iterators_nd()
270 static_vector
<T
, N
> s
;
273 for ( size_t i
= 0 ; i
< N
; ++i
)
275 s
.push_back(T((int)i
));
276 v
.push_back(T((int)i
));
279 test_compare_ranges(s
.begin(), s
.end(), v
.begin(), v
.end());
280 test_compare_ranges(s
.rbegin(), s
.rend(), v
.rbegin(), v
.rend());
282 s
.assign(v
.rbegin(), v
.rend());
284 test_compare_ranges(s
.begin(), s
.end(), v
.rbegin(), v
.rend());
285 test_compare_ranges(s
.rbegin(), s
.rend(), v
.begin(), v
.end());
288 template <typename T
, size_t N
>
291 static_vector
<T
, N
> s
;
292 typedef typename static_vector
<T
, N
>::iterator It
;
294 for ( size_t i
= 0 ; i
< N
; ++i
)
295 s
.push_back(T((int)i
));
299 for ( size_t i
= 0 ; i
< N
; ++i
)
301 static_vector
<T
, N
> s1(s
);
302 It it
= s1
.erase(s1
.begin() + i
);
303 BOOST_TEST(s1
.begin() + i
== it
);
304 BOOST_TEST(s1
.size() == N
- 1);
305 for ( size_t j
= 0 ; j
< i
; ++j
)
306 BOOST_TEST(s1
[j
] == T((int)j
));
307 for ( size_t j
= i
+1 ; j
< N
; ++j
)
308 BOOST_TEST(s1
[j
-1] == T((int)j
));
311 // erase(first, last)
314 for ( size_t i
= 0 ; i
<= N
; ++i
)
316 static_vector
<T
, N
> s1(s
);
317 size_t removed
= i
+ n
< N
? n
: N
- i
;
318 It it
= s1
.erase(s1
.begin() + i
, s1
.begin() + i
+ removed
);
319 BOOST_TEST(s1
.begin() + i
== it
);
320 BOOST_TEST(s1
.size() == N
- removed
);
321 for ( size_t j
= 0 ; j
< i
; ++j
)
322 BOOST_TEST(s1
[j
] == T((int)j
));
323 for ( size_t j
= i
+n
; j
< N
; ++j
)
324 BOOST_TEST(s1
[j
-n
] == T((int)j
));
329 template <typename T
, size_t N
, typename SV
, typename C
>
330 void test_insert(SV
const& s
, C
const& c
)
333 size_t n
= size_t(h
/1.5f
);
335 for ( size_t i
= 0 ; i
<= h
; ++i
)
337 static_vector
<T
, N
> s1(s
);
339 typename
C::const_iterator it
= c
.begin();
340 boost::container::iterator_advance(it
, n
);
341 typename static_vector
<T
, N
>::iterator
342 it1
= s1
.insert(s1
.begin() + i
, c
.begin(), it
);
344 BOOST_TEST(s1
.begin() + i
== it1
);
345 BOOST_TEST(s1
.size() == h
+n
);
346 for ( size_t j
= 0 ; j
< i
; ++j
)
347 BOOST_TEST(s1
[j
] == T((int)j
));
348 for ( size_t j
= 0 ; j
< n
; ++j
)
349 BOOST_TEST(s1
[j
+i
] == T(100 + (int)j
));
350 for ( size_t j
= 0 ; j
< h
-i
; ++j
)
351 BOOST_TEST(s1
[j
+i
+n
] == T((int)j
+(int)i
));
355 template <typename T
, size_t N
>
356 void test_insert_nd(T
const& val
)
360 static_vector
<T
, N
> s
, ss
;
364 typedef typename static_vector
<T
, N
>::iterator It
;
366 for ( size_t i
= 0 ; i
< h
; ++i
)
368 s
.push_back(T((int)i
));
369 ss
.push_back(T(100 + (int)i
));
370 v
.push_back(T(100 + (int)i
));
371 l
.push_back(T(100 + (int)i
));
376 for ( size_t i
= 0 ; i
<= h
; ++i
)
378 static_vector
<T
, N
> s1(s
);
379 It it
= s1
.insert(s1
.begin() + i
, val
);
380 BOOST_TEST(s1
.begin() + i
== it
);
381 BOOST_TEST(s1
.size() == h
+1);
382 for ( size_t j
= 0 ; j
< i
; ++j
)
383 BOOST_TEST(s1
[j
] == T((int)j
));
384 BOOST_TEST(s1
[i
] == val
);
385 for ( size_t j
= 0 ; j
< h
-i
; ++j
)
386 BOOST_TEST(s1
[j
+i
+1] == T((int)j
+(int)i
));
389 // insert(pos, n, val)
391 size_t n
= size_t(h
/1.5f
);
392 for ( size_t i
= 0 ; i
<= h
; ++i
)
394 static_vector
<T
, N
> s1(s
);
395 It it
= s1
.insert(s1
.begin() + i
, n
, val
);
396 BOOST_TEST(s1
.begin() + i
== it
);
397 BOOST_TEST(s1
.size() == h
+n
);
398 for ( size_t j
= 0 ; j
< i
; ++j
)
399 BOOST_TEST(s1
[j
] == T((int)j
));
400 for ( size_t j
= 0 ; j
< n
; ++j
)
401 BOOST_TEST(s1
[j
+i
] == val
);
402 for ( size_t j
= 0 ; j
< h
-i
; ++j
)
403 BOOST_TEST(s1
[j
+i
+n
] == T((int)j
+(int)i
));
406 // insert(pos, first, last)
407 test_insert
<T
, N
>(s
, ss
);
408 test_insert
<T
, N
>(s
, v
);
409 test_insert
<T
, N
>(s
, l
);
412 template <typename T
>
413 void test_capacity_0_nd()
415 static_vector
<T
, 10> v(5u, T(0));
417 typedef static_vector
<T
, 0> static_vector_0_t
;
419 BOOST_TEST(s
.size() == 0);
420 BOOST_TEST(s
.capacity() == 0);
421 BOOST_TEST_THROWS(s
.at(0), std::out_of_range
);
422 BOOST_TEST_THROWS(s
.resize(5u, T(0)), std::bad_alloc
);
423 BOOST_TEST_THROWS(s
.push_back(T(0)), std::bad_alloc
);
424 BOOST_TEST_THROWS(s
.insert(s
.end(), T(0)), std::bad_alloc
);
425 BOOST_TEST_THROWS(s
.insert(s
.end(), 5u, T(0)), std::bad_alloc
);
426 BOOST_TEST_THROWS(s
.insert(s
.end(), v
.begin(), v
.end()), std::bad_alloc
);
427 BOOST_TEST_THROWS(s
.assign(v
.begin(), v
.end()), std::bad_alloc
);
428 BOOST_TEST_THROWS(s
.assign(5u, T(0)), std::bad_alloc
);
429 BOOST_TEST_THROWS(s
.assign(5u, T(0)), std::bad_alloc
);
430 BOOST_TEST_THROWS(static_vector_0_t
s2(v
.begin(), v
.end()), std::bad_alloc
);
431 BOOST_TEST_THROWS(static_vector_0_t
s1(5u, T(0)), std::bad_alloc
);
434 template <typename T
, size_t N
>
435 void test_exceptions_nd()
437 static_vector
<T
, N
> v(N
, T(0));
438 typedef static_vector
<T
, N
/2> static_vector_n_half_t
;
439 static_vector_n_half_t
s(N
/2, T(0));
441 BOOST_TEST_THROWS(s
.resize(N
, T(0)), std::bad_alloc
);
442 BOOST_TEST_THROWS(s
.push_back(T(0)), std::bad_alloc
);
443 BOOST_TEST_THROWS(s
.insert(s
.end(), T(0)), std::bad_alloc
);
444 BOOST_TEST_THROWS(s
.insert(s
.end(), 1, T(0)), std::bad_alloc
);
445 BOOST_TEST_THROWS(s
.insert(s
.end(), v
.begin(), v
.end()), std::bad_alloc
);
446 BOOST_TEST_THROWS(s
.assign(v
.begin(), v
.end()), std::bad_alloc
);
447 BOOST_TEST_THROWS(s
.assign(N
, T(0)), std::bad_alloc
);
448 BOOST_TEST_THROWS(static_vector_n_half_t
s2(v
.begin(), v
.end()), std::bad_alloc
);
449 BOOST_TEST_THROWS(static_vector_n_half_t
s1(N
/2+1, T(0)), std::bad_alloc
);
452 template <typename T
, size_t N
>
453 void test_swap_and_move_nd()
456 static_vector
<T
, N
> v1
, v2
, v3
, v4
;
457 static_vector
<T
, N
> s1
, s2
;
458 static_vector
<T
, N
> s4
;
460 for (size_t i
= 0 ; i
< N
; ++i
)
462 v1
.push_back(T((int)i
));
463 v2
.push_back(T((int)i
));
464 v3
.push_back(T((int)i
));
465 v4
.push_back(T((int)i
));
467 for (size_t i
= 0 ; i
< N
/2 ; ++i
)
469 s1
.push_back(T(100 + (int)i
));
470 s2
.push_back(T(100 + (int)i
));
471 s4
.push_back(T(100 + (int)i
));
475 s2
= boost::move(v2
);
476 static_vector
<T
, N
> s3(boost::move(v3
));
479 BOOST_TEST(v1
.size() == N
/2);
480 BOOST_TEST(s1
.size() == N
);
481 BOOST_TEST(v2
.size() == 0);
482 BOOST_TEST(s2
.size() == N
);
483 BOOST_TEST(v3
.size() == 0);
484 BOOST_TEST(s3
.size() == N
);
485 BOOST_TEST(v4
.size() == N
/2);
486 BOOST_TEST(s4
.size() == N
);
487 for (size_t i
= 0 ; i
< N
/2 ; ++i
)
489 BOOST_TEST(v1
[i
] == T(100 + (int)i
));
490 BOOST_TEST(v4
[i
] == T(100 + (int)i
));
492 for (size_t i
= 0 ; i
< N
; ++i
)
494 BOOST_TEST(s1
[i
] == T((int)i
));
495 BOOST_TEST(s2
[i
] == T((int)i
));
496 BOOST_TEST(s3
[i
] == T((int)i
));
497 BOOST_TEST(s4
[i
] == T((int)i
));
501 static_vector
<T
, N
> v1
, v2
, v3
;
502 static_vector
<T
, N
/2> s1
, s2
, s3
;
504 for (size_t i
= 0 ; i
< N
/2 ; ++i
)
506 v1
.push_back(T((int)i
));
507 v2
.push_back(T((int)i
));
508 v3
.push_back(T((int)i
));
510 for (size_t i
= 0 ; i
< N
/3 ; ++i
)
512 s1
.push_back(T(100 + (int)i
));
513 s2
.push_back(T(100 + (int)i
));
518 s2
= boost::move(v2
);
519 static_vector
<T
, N
/2> s4(boost::move(v3
));
521 BOOST_TEST(v1
.size() == N
/3);
522 BOOST_TEST(s1
.size() == N
/2);
523 //iG moving does not imply emptying source
524 //BOOST_TEST(v2.size() == 0);
525 BOOST_TEST(s2
.size() == N
/2);
526 BOOST_TEST(s3
.size() == N
/2);
527 //iG moving does not imply emptying source
528 //BOOST_TEST(v3.size() == 0);
529 BOOST_TEST(s4
.size() == N
/2);
530 for (size_t i
= 0 ; i
< N
/3 ; ++i
)
531 BOOST_TEST(v1
[i
] == T(100 + (int)i
));
532 for (size_t i
= 0 ; i
< N
/2 ; ++i
)
534 BOOST_TEST(s1
[i
] == T((int)i
));
535 BOOST_TEST(s2
[i
] == T((int)i
));
536 BOOST_TEST(s3
[i
] == T((int)i
));
537 BOOST_TEST(s4
[i
] == T((int)i
));
541 typedef static_vector
<T
, N
/2> small_vector_t
;
542 static_vector
<T
, N
> v(N
, T(0));
543 small_vector_t
s(N
/2, T(1));
544 BOOST_TEST_THROWS(s
.swap(v
), std::bad_alloc
);
546 BOOST_TEST_THROWS(s
= boost::move(v
), std::bad_alloc
);
547 BOOST_TEST_THROWS(s
= v
, std::bad_alloc
);
549 BOOST_TEST_THROWS(small_vector_t
s2(boost::move(v
)), std::bad_alloc
);
553 template <typename T
, size_t N
>
554 void test_emplace_0p()
558 static_vector
<T
, N
> v
;
560 for (int i
= 0 ; i
< int(N
) ; ++i
)
562 BOOST_TEST(v
.size() == N
);
563 BOOST_TEST_THROWS(v
.emplace_back(), std::bad_alloc
);
567 template <typename T
, size_t N
>
568 void test_emplace_2p()
570 //emplace_back(pos, int, int)
572 static_vector
<T
, N
> v
;
574 for (int i
= 0 ; i
< int(N
) ; ++i
)
575 v
.emplace_back(i
, 100 + i
);
576 BOOST_TEST(v
.size() == N
);
577 BOOST_TEST_THROWS(v
.emplace_back((int)N
, 100 + (int)N
), std::bad_alloc
);
578 BOOST_TEST(v
.size() == N
);
579 for (int i
= 0 ; i
< int(N
) ; ++i
)
580 BOOST_TEST(v
[i
] == T(i
, 100 + i
));
583 // emplace(pos, int, int)
585 typedef typename static_vector
<T
, N
>::iterator It
;
589 static_vector
<T
, N
> v
;
590 for ( int i
= 0 ; i
< h
; ++i
)
591 v
.emplace_back(i
, 100 + i
);
593 for ( int i
= 0 ; i
<= h
; ++i
)
595 static_vector
<T
, N
> vv(v
);
596 It it
= vv
.emplace(vv
.begin() + i
, i
+100, i
+200);
597 BOOST_TEST(vv
.begin() + i
== it
);
598 BOOST_TEST(vv
.size() == size_t(h
+1));
599 for ( int j
= 0 ; j
< i
; ++j
)
600 BOOST_TEST(vv
[j
] == T(j
, j
+100));
601 BOOST_TEST(vv
[i
] == T(i
+100, i
+200));
602 for ( int j
= 0 ; j
< h
-i
; ++j
)
603 BOOST_TEST(vv
[j
+i
+1] == T(j
+i
, j
+i
+100));
608 template <typename T
, size_t N
>
609 void test_sv_elem(T
const& t
)
611 typedef static_vector
<T
, N
> V
;
613 static_vector
<V
, N
> v
;
615 v
.push_back(V(N
/2, t
));
617 v
.push_back(boost::move(vvv
));
618 v
.insert(v
.begin(), V(N
/2, t
));
619 v
.insert(v
.end(), V(N
/2, t
));
620 v
.emplace_back(N
/2, t
);
623 bool default_init_test()//Test for default initialization
625 const std::size_t Capacity
= 100;
627 typedef static_vector
<int, Capacity
> di_vector_t
;
630 di_vector_t
v(Capacity
, default_init
);
636 for(std::size_t i
= 0; i
!= Capacity
; ++i
, ++p
){
637 *p
= static_cast<int>(i
);
640 //Destroy the vector, p still pointing to the storage
643 di_vector_t
&rv
= *::new(&v
)di_vector_t(Capacity
, default_init
);
644 di_vector_t::iterator it
= rv
.begin();
646 for(std::size_t i
= 0; i
!= Capacity
; ++i
, ++it
){
647 if(*it
!= static_cast<int>(i
))
657 for(std::size_t i
= 0; i
!= Capacity
; ++i
, ++p
){
658 *p
= static_cast<int>(i
+100);
661 v
.resize(Capacity
, default_init
);
663 di_vector_t::iterator it
= v
.begin();
664 for(std::size_t i
= 0; i
!= Capacity
; ++i
, ++it
){
665 if(*it
!= static_cast<int>(i
+100))
674 int main(int, char* [])
676 using boost::container::test::movable_and_copyable_int
;
677 using boost::container::test::produce_movable_and_copyable_int
;
678 BOOST_TEST(counting_value::count() == 0);
680 test_ctor_ndc
<int, 10>();
681 test_ctor_ndc
<value_ndc
, 10>();
682 test_ctor_ndc
<counting_value
, 10>();
683 BOOST_TEST(counting_value::count() == 0);
684 test_ctor_ndc
<movable_and_copyable_int
, 10>();
686 test_ctor_nc
<int, 10>(5);
687 test_ctor_nc
<value_nc
, 10>(5);
688 test_ctor_nc
<counting_value
, 10>(5);
689 BOOST_TEST(counting_value::count() == 0);
690 test_ctor_nc
<movable_and_copyable_int
, 10>(5);
692 test_ctor_nd
<int, 10>(5, 1);
693 test_ctor_nd
<value_nd
, 10>(5, value_nd(1));
694 test_ctor_nd
<counting_value
, 10>(5, counting_value(1));
695 BOOST_TEST(counting_value::count() == 0);
696 test_ctor_nd
<movable_and_copyable_int
, 10>(5, produce_movable_and_copyable_int());
698 test_resize_nc
<int, 10>(5);
699 test_resize_nc
<value_nc
, 10>(5);
700 test_resize_nc
<counting_value
, 10>(5);
701 BOOST_TEST(counting_value::count() == 0);
702 test_resize_nc
<movable_and_copyable_int
, 10>(5);
704 test_resize_nd
<int, 10>(5, 1);
705 test_resize_nd
<value_nd
, 10>(5, value_nd(1));
706 test_resize_nd
<counting_value
, 10>(5, counting_value(1));
707 BOOST_TEST(counting_value::count() == 0);
708 test_resize_nd
<movable_and_copyable_int
, 10>(5, produce_movable_and_copyable_int());
710 test_push_back_nd
<int, 10>();
711 test_push_back_nd
<value_nd
, 10>();
712 test_push_back_nd
<counting_value
, 10>();
713 BOOST_TEST(counting_value::count() == 0);
714 test_push_back_nd
<movable_and_copyable_int
, 10>();
716 test_pop_back_nd
<int, 10>();
717 test_pop_back_nd
<value_nd
, 10>();
718 test_pop_back_nd
<counting_value
, 10>();
719 BOOST_TEST(counting_value::count() == 0);
720 test_pop_back_nd
<movable_and_copyable_int
, 10>();
722 test_copy_and_assign_nd
<int, 10>(1);
723 test_copy_and_assign_nd
<value_nd
, 10>(value_nd(1));
724 test_copy_and_assign_nd
<counting_value
, 10>(counting_value(1));
725 BOOST_TEST(counting_value::count() == 0);
726 test_copy_and_assign_nd
<movable_and_copyable_int
, 10>(produce_movable_and_copyable_int());
728 test_iterators_nd
<int, 10>();
729 test_iterators_nd
<value_nd
, 10>();
730 test_iterators_nd
<counting_value
, 10>();
731 BOOST_TEST(counting_value::count() == 0);
732 test_iterators_nd
<movable_and_copyable_int
, 10>();
734 test_erase_nd
<int, 10>();
735 test_erase_nd
<value_nd
, 10>();
736 test_erase_nd
<counting_value
, 10>();
737 BOOST_TEST(counting_value::count() == 0);
738 test_erase_nd
<movable_and_copyable_int
, 10>();
740 test_insert_nd
<int, 10>(50);
741 test_insert_nd
<value_nd
, 10>(value_nd(50));
742 test_insert_nd
<counting_value
, 10>(counting_value(50));
743 BOOST_TEST(counting_value::count() == 0);
744 test_insert_nd
<movable_and_copyable_int
, 10>(produce_movable_and_copyable_int());
746 test_capacity_0_nd
<int>();
747 test_capacity_0_nd
<value_nd
>();
748 test_capacity_0_nd
<counting_value
>();
749 BOOST_TEST(counting_value::count() == 0);
750 test_capacity_0_nd
<movable_and_copyable_int
>();
752 test_exceptions_nd
<int, 10>();
753 test_exceptions_nd
<value_nd
, 10>();
754 test_exceptions_nd
<counting_value
, 10>();
755 BOOST_TEST(counting_value::count() == 0);
756 test_exceptions_nd
<movable_and_copyable_int
, 10>();
758 test_swap_and_move_nd
<int, 10>();
759 test_swap_and_move_nd
<value_nd
, 10>();
760 test_swap_and_move_nd
<counting_value
, 10>();
761 BOOST_TEST(counting_value::count() == 0);
762 test_swap_and_move_nd
<movable_and_copyable_int
, 10>();
764 test_emplace_0p
<counting_value
, 10>();
765 BOOST_TEST(counting_value::count() == 0);
767 test_emplace_2p
<counting_value
, 10>();
768 BOOST_TEST(counting_value::count() == 0);
770 test_sv_elem
<int, 10>(50);
771 test_sv_elem
<value_nd
, 10>(value_nd(50));
772 test_sv_elem
<counting_value
, 10>(counting_value(50));
773 BOOST_TEST(counting_value::count() == 0);
774 test_sv_elem
<movable_and_copyable_int
, 10>(movable_and_copyable_int(50));
776 BOOST_TEST(default_init_test() == true);
778 test_support_for_initializer_list();
780 ////////////////////////////////////
782 ////////////////////////////////////
784 typedef boost::container::static_vector
<int, 3> cont_int
;
785 cont_int a
; a
.push_back(0); a
.push_back(1); a
.push_back(2);
786 boost::intrusive::test::test_iterator_random
< cont_int
>(a
);
789 return boost::report_errors();
794 #include <boost/container/small_vector.hpp>
795 #include <type_traits>
800 static_assert(std::is_nothrow_move_constructible<S_trivial>::value, "");
801 static_assert(std::is_nothrow_move_assignable<S_trivial>::value, "");
806 static_assert(std::is_nothrow_move_constructible<S1>::value, "");
807 static_assert(std::is_nothrow_move_assignable<S1>::value, "");
812 S2& operator=(S2&&) noexcept;
814 static_assert(std::is_nothrow_move_constructible<S2>::value, "");
815 static_assert(std::is_nothrow_move_assignable<S2>::value, "");
818 static_assert(std::is_nothrow_move_constructible<boost::container::small_vector<S_trivial, 1>>::value, "");
819 static_assert(std::is_nothrow_move_assignable<boost::container::small_vector<S_trivial, 1>>::value, "");
822 static_assert(std::is_nothrow_move_constructible<boost::container::small_vector<S1, 1>>::value, "");
823 static_assert(std::is_nothrow_move_assignable<boost::container::small_vector<S1, 1>>::value, "");
826 static_assert(std::is_nothrow_move_constructible<boost::container::small_vector<S2, 1>>::value, "");
827 static_assert(std::is_nothrow_move_assignable<boost::container::small_vector<S2, 1>>::value, "");