15a83710eSEric Fiselier //===----------------------------------------------------------------------===//
25a83710eSEric Fiselier //
357b08b09SChandler Carruth // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
457b08b09SChandler Carruth // See https://llvm.org/LICENSE.txt for license information.
557b08b09SChandler Carruth // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
65a83710eSEric Fiselier //
75a83710eSEric Fiselier //===----------------------------------------------------------------------===//
85a83710eSEric Fiselier
9*31cbe0f2SLouis Dionne // UNSUPPORTED: c++03
10a9d646a0SEric Fiselier
115a83710eSEric Fiselier // <deque>
125a83710eSEric Fiselier
135a83710eSEric Fiselier // deque& operator=(deque&& c);
145a83710eSEric Fiselier
155a83710eSEric Fiselier #include <deque>
165a83710eSEric Fiselier #include <cassert>
175a83710eSEric Fiselier
187fc6a556SMarshall Clow #include "test_macros.h"
19949389c3SMarshall Clow #include "MoveOnly.h"
205a83710eSEric Fiselier #include "test_allocator.h"
215a83710eSEric Fiselier #include "min_allocator.h"
225a83710eSEric Fiselier
main(int,char **)232df59c50SJF Bastien int main(int, char**)
245a83710eSEric Fiselier {
255a83710eSEric Fiselier {
265a83710eSEric Fiselier int ab[] = {3, 4, 2, 8, 0, 1, 44, 34, 45, 96, 80, 1, 13, 31, 45};
275a83710eSEric Fiselier int* an = ab + sizeof(ab)/sizeof(ab[0]);
285a83710eSEric Fiselier typedef test_allocator<MoveOnly> A;
295a83710eSEric Fiselier std::deque<MoveOnly, A> c1(A(5));
305a83710eSEric Fiselier for (int* p = ab; p < an; ++p)
315a83710eSEric Fiselier c1.push_back(MoveOnly(*p));
325a83710eSEric Fiselier std::deque<MoveOnly, A> c2(A(5));
335a83710eSEric Fiselier for (int* p = ab; p < an; ++p)
345a83710eSEric Fiselier c2.push_back(MoveOnly(*p));
355a83710eSEric Fiselier std::deque<MoveOnly, A> c3(A(5));
365a83710eSEric Fiselier c3 = std::move(c1);
375a83710eSEric Fiselier assert(c2 == c3);
385a83710eSEric Fiselier assert(c1.size() == 0);
395a83710eSEric Fiselier assert(c3.get_allocator() == A(5));
405a83710eSEric Fiselier }
415a83710eSEric Fiselier {
425a83710eSEric Fiselier int ab[] = {3, 4, 2, 8, 0, 1, 44, 34, 45, 96, 80, 1, 13, 31, 45};
435a83710eSEric Fiselier int* an = ab + sizeof(ab)/sizeof(ab[0]);
445a83710eSEric Fiselier typedef test_allocator<MoveOnly> A;
455a83710eSEric Fiselier std::deque<MoveOnly, A> c1(A(5));
465a83710eSEric Fiselier for (int* p = ab; p < an; ++p)
475a83710eSEric Fiselier c1.push_back(MoveOnly(*p));
485a83710eSEric Fiselier std::deque<MoveOnly, A> c2(A(5));
495a83710eSEric Fiselier for (int* p = ab; p < an; ++p)
505a83710eSEric Fiselier c2.push_back(MoveOnly(*p));
515a83710eSEric Fiselier std::deque<MoveOnly, A> c3(A(6));
525a83710eSEric Fiselier c3 = std::move(c1);
535a83710eSEric Fiselier assert(c2 == c3);
545a83710eSEric Fiselier assert(c1.size() != 0);
555a83710eSEric Fiselier assert(c3.get_allocator() == A(6));
565a83710eSEric Fiselier }
575a83710eSEric Fiselier {
585a83710eSEric Fiselier int ab[] = {3, 4, 2, 8, 0, 1, 44, 34, 45, 96, 80, 1, 13, 31, 45};
595a83710eSEric Fiselier int* an = ab + sizeof(ab)/sizeof(ab[0]);
605a83710eSEric Fiselier typedef other_allocator<MoveOnly> A;
615a83710eSEric Fiselier std::deque<MoveOnly, A> c1(A(5));
625a83710eSEric Fiselier for (int* p = ab; p < an; ++p)
635a83710eSEric Fiselier c1.push_back(MoveOnly(*p));
645a83710eSEric Fiselier std::deque<MoveOnly, A> c2(A(5));
655a83710eSEric Fiselier for (int* p = ab; p < an; ++p)
665a83710eSEric Fiselier c2.push_back(MoveOnly(*p));
675a83710eSEric Fiselier std::deque<MoveOnly, A> c3(A(6));
685a83710eSEric Fiselier c3 = std::move(c1);
695a83710eSEric Fiselier assert(c2 == c3);
705a83710eSEric Fiselier assert(c1.size() == 0);
715a83710eSEric Fiselier assert(c3.get_allocator() == A(5));
725a83710eSEric Fiselier }
735a83710eSEric Fiselier {
745a83710eSEric Fiselier int ab[] = {3, 4, 2, 8, 0, 1, 44, 34, 45, 96, 80, 1, 13, 31, 45};
755a83710eSEric Fiselier int* an = ab + sizeof(ab)/sizeof(ab[0]);
765a83710eSEric Fiselier typedef min_allocator<MoveOnly> A;
775a83710eSEric Fiselier std::deque<MoveOnly, A> c1(A{});
785a83710eSEric Fiselier for (int* p = ab; p < an; ++p)
795a83710eSEric Fiselier c1.push_back(MoveOnly(*p));
805a83710eSEric Fiselier std::deque<MoveOnly, A> c2(A{});
815a83710eSEric Fiselier for (int* p = ab; p < an; ++p)
825a83710eSEric Fiselier c2.push_back(MoveOnly(*p));
835a83710eSEric Fiselier std::deque<MoveOnly, A> c3(A{});
845a83710eSEric Fiselier c3 = std::move(c1);
855a83710eSEric Fiselier assert(c2 == c3);
865a83710eSEric Fiselier assert(c1.size() == 0);
875a83710eSEric Fiselier assert(c3.get_allocator() == A());
885a83710eSEric Fiselier }
892df59c50SJF Bastien
902df59c50SJF Bastien return 0;
915a83710eSEric Fiselier }
92