1 //===----------------------------------------------------------------------===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is dual licensed under the MIT and the University of Illinois Open
6 // Source Licenses. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9
10 // <vector>
11
12 // vector(vector&& c, const allocator_type& a);
13
14 #include <vector>
15 #include <cassert>
16 #include "test_allocator.h"
17 #include "min_allocator.h"
18
main()19 int main()
20 {
21 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
22 {
23 std::vector<bool, test_allocator<bool> > l(test_allocator<bool>(5));
24 std::vector<bool, test_allocator<bool> > lo(test_allocator<bool>(5));
25 for (int i = 1; i <= 3; ++i)
26 {
27 l.push_back(i);
28 lo.push_back(i);
29 }
30 std::vector<bool, test_allocator<bool> > l2(std::move(l), test_allocator<bool>(6));
31 assert(l2 == lo);
32 assert(!l.empty());
33 assert(l2.get_allocator() == test_allocator<bool>(6));
34 }
35 {
36 std::vector<bool, test_allocator<bool> > l(test_allocator<bool>(5));
37 std::vector<bool, test_allocator<bool> > lo(test_allocator<bool>(5));
38 for (int i = 1; i <= 3; ++i)
39 {
40 l.push_back(i);
41 lo.push_back(i);
42 }
43 std::vector<bool, test_allocator<bool> > l2(std::move(l), test_allocator<bool>(5));
44 assert(l2 == lo);
45 assert(l.empty());
46 assert(l2.get_allocator() == test_allocator<bool>(5));
47 }
48 {
49 std::vector<bool, other_allocator<bool> > l(other_allocator<bool>(5));
50 std::vector<bool, other_allocator<bool> > lo(other_allocator<bool>(5));
51 for (int i = 1; i <= 3; ++i)
52 {
53 l.push_back(i);
54 lo.push_back(i);
55 }
56 std::vector<bool, other_allocator<bool> > l2(std::move(l), other_allocator<bool>(4));
57 assert(l2 == lo);
58 assert(!l.empty());
59 assert(l2.get_allocator() == other_allocator<bool>(4));
60 }
61 #if __cplusplus >= 201103L
62 {
63 std::vector<bool, min_allocator<bool> > l(min_allocator<bool>{});
64 std::vector<bool, min_allocator<bool> > lo(min_allocator<bool>{});
65 for (int i = 1; i <= 3; ++i)
66 {
67 l.push_back(i);
68 lo.push_back(i);
69 }
70 std::vector<bool, min_allocator<bool> > l2(std::move(l), min_allocator<bool>());
71 assert(l2 == lo);
72 assert(l.empty());
73 assert(l2.get_allocator() == min_allocator<bool>());
74 }
75 #endif
76 #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
77 }
78