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 // <deque>
11
12 // deque(deque&&);
13
14 #include <deque>
15 #include <cassert>
16
17 #include "../../../MoveOnly.h"
18 #include "test_allocator.h"
19 #include "min_allocator.h"
20
main()21 int main()
22 {
23 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
24 {
25 int ab[] = {3, 4, 2, 8, 0, 1, 44, 34, 45, 96, 80, 1, 13, 31, 45};
26 int* an = ab + sizeof(ab)/sizeof(ab[0]);
27 typedef test_allocator<MoveOnly> A;
28 std::deque<MoveOnly, A> c1(A(1));
29 for (int* p = ab; p < an; ++p)
30 c1.push_back(MoveOnly(*p));
31 std::deque<MoveOnly, A> c2(A(2));
32 for (int* p = ab; p < an; ++p)
33 c2.push_back(MoveOnly(*p));
34 std::deque<MoveOnly, A> c3 = std::move(c1);
35 assert(c2 == c3);
36 assert(c1.size() == 0);
37 assert(c3.get_allocator() == c1.get_allocator());
38 }
39 {
40 int ab[] = {3, 4, 2, 8, 0, 1, 44, 34, 45, 96, 80, 1, 13, 31, 45};
41 int* an = ab + sizeof(ab)/sizeof(ab[0]);
42 typedef other_allocator<MoveOnly> A;
43 std::deque<MoveOnly, A> c1(A(1));
44 for (int* p = ab; p < an; ++p)
45 c1.push_back(MoveOnly(*p));
46 std::deque<MoveOnly, A> c2(A(2));
47 for (int* p = ab; p < an; ++p)
48 c2.push_back(MoveOnly(*p));
49 std::deque<MoveOnly, A> c3 = std::move(c1);
50 assert(c2 == c3);
51 assert(c1.size() == 0);
52 assert(c3.get_allocator() == c1.get_allocator());
53 }
54 #if __cplusplus >= 201103L
55 {
56 int ab[] = {3, 4, 2, 8, 0, 1, 44, 34, 45, 96, 80, 1, 13, 31, 45};
57 int* an = ab + sizeof(ab)/sizeof(ab[0]);
58 typedef min_allocator<MoveOnly> A;
59 std::deque<MoveOnly, A> c1(A{});
60 for (int* p = ab; p < an; ++p)
61 c1.push_back(MoveOnly(*p));
62 std::deque<MoveOnly, A> c2(A{});
63 for (int* p = ab; p < an; ++p)
64 c2.push_back(MoveOnly(*p));
65 std::deque<MoveOnly, A> c3 = std::move(c1);
66 assert(c2 == c3);
67 assert(c1.size() == 0);
68 assert(c3.get_allocator() == c1.get_allocator());
69 }
70 #endif
71 #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
72 }
73