1 //===----------------------------------------------------------------------===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
13 // deque& operator=(deque&& c);
18 #include "test_macros.h"
20 #include "test_allocator.h"
21 #include "min_allocator.h"
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(5));
30 for (int* p
= ab
; p
< an
; ++p
)
31 c1
.push_back(MoveOnly(*p
));
32 std::deque
<MoveOnly
, A
> c2(A(5));
33 for (int* p
= ab
; p
< an
; ++p
)
34 c2
.push_back(MoveOnly(*p
));
35 std::deque
<MoveOnly
, A
> c3(A(5));
38 assert(c1
.size() == 0);
39 assert(c3
.get_allocator() == A(5));
42 int ab
[] = {3, 4, 2, 8, 0, 1, 44, 34, 45, 96, 80, 1, 13, 31, 45};
43 int* an
= ab
+ sizeof(ab
)/sizeof(ab
[0]);
44 typedef test_allocator
<MoveOnly
> A
;
45 std::deque
<MoveOnly
, A
> c1(A(5));
46 for (int* p
= ab
; p
< an
; ++p
)
47 c1
.push_back(MoveOnly(*p
));
48 std::deque
<MoveOnly
, A
> c2(A(5));
49 for (int* p
= ab
; p
< an
; ++p
)
50 c2
.push_back(MoveOnly(*p
));
51 std::deque
<MoveOnly
, A
> c3(A(6));
54 assert(c1
.size() != 0);
55 assert(c3
.get_allocator() == A(6));
58 int ab
[] = {3, 4, 2, 8, 0, 1, 44, 34, 45, 96, 80, 1, 13, 31, 45};
59 int* an
= ab
+ sizeof(ab
)/sizeof(ab
[0]);
60 typedef other_allocator
<MoveOnly
> A
;
61 std::deque
<MoveOnly
, A
> c1(A(5));
62 for (int* p
= ab
; p
< an
; ++p
)
63 c1
.push_back(MoveOnly(*p
));
64 std::deque
<MoveOnly
, A
> c2(A(5));
65 for (int* p
= ab
; p
< an
; ++p
)
66 c2
.push_back(MoveOnly(*p
));
67 std::deque
<MoveOnly
, A
> c3(A(6));
70 assert(c1
.size() == 0);
71 assert(c3
.get_allocator() == A(5));
74 int ab
[] = {3, 4, 2, 8, 0, 1, 44, 34, 45, 96, 80, 1, 13, 31, 45};
75 int* an
= ab
+ sizeof(ab
)/sizeof(ab
[0]);
76 typedef min_allocator
<MoveOnly
> A
;
77 std::deque
<MoveOnly
, A
> c1(A
{});
78 for (int* p
= ab
; p
< an
; ++p
)
79 c1
.push_back(MoveOnly(*p
));
80 std::deque
<MoveOnly
, A
> c2(A
{});
81 for (int* p
= ab
; p
< an
; ++p
)
82 c2
.push_back(MoveOnly(*p
));
83 std::deque
<MoveOnly
, A
> c3(A
{});
86 assert(c1
.size() == 0);
87 assert(c3
.get_allocator() == A());