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 // UNSUPPORTED: c++98, c++03
11 
12 // <deque>
13 
14 // deque(deque&&);
15 
16 #include <deque>
17 #include <cassert>
18 
19 #include "MoveOnly.h"
20 #include "test_allocator.h"
21 #include "min_allocator.h"
22 
23 int main()
24 {
25     {
26         int ab[] = {3, 4, 2, 8, 0, 1, 44, 34, 45, 96, 80, 1, 13, 31, 45};
27         int* an = ab + sizeof(ab)/sizeof(ab[0]);
28         typedef test_allocator<MoveOnly> A;
29         std::deque<MoveOnly, A> c1(A(1));
30         for (int* p = ab; p < an; ++p)
31             c1.push_back(MoveOnly(*p));
32         std::deque<MoveOnly, A> c2(A(2));
33         for (int* p = ab; p < an; ++p)
34             c2.push_back(MoveOnly(*p));
35         std::deque<MoveOnly, A> c3 = std::move(c1);
36         assert(c2 == c3);
37         assert(c1.size() == 0);
38         assert(c3.get_allocator() == c1.get_allocator());
39     }
40     {
41         int ab[] = {3, 4, 2, 8, 0, 1, 44, 34, 45, 96, 80, 1, 13, 31, 45};
42         int* an = ab + sizeof(ab)/sizeof(ab[0]);
43         typedef other_allocator<MoveOnly> A;
44         std::deque<MoveOnly, A> c1(A(1));
45         for (int* p = ab; p < an; ++p)
46             c1.push_back(MoveOnly(*p));
47         std::deque<MoveOnly, A> c2(A(2));
48         for (int* p = ab; p < an; ++p)
49             c2.push_back(MoveOnly(*p));
50         std::deque<MoveOnly, A> c3 = std::move(c1);
51         assert(c2 == c3);
52         assert(c1.size() == 0);
53         assert(c3.get_allocator() == c1.get_allocator());
54     }
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 }
71