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
931cbe0f2SLouis Dionne // UNSUPPORTED: c++03
10843d9101SEric Fiselier
115a83710eSEric Fiselier // <vector>
125a83710eSEric Fiselier
135a83710eSEric Fiselier // vector(vector&& c, const allocator_type& a);
145a83710eSEric Fiselier
155a83710eSEric Fiselier #include <vector>
165a83710eSEric Fiselier #include <cassert>
177fc6a556SMarshall Clow #include "test_macros.h"
185a83710eSEric Fiselier #include "test_allocator.h"
195a83710eSEric Fiselier #include "min_allocator.h"
205a83710eSEric Fiselier
tests()21*c74059c5SNikolas Klauser TEST_CONSTEXPR_CXX20 bool tests()
225a83710eSEric Fiselier {
235a83710eSEric Fiselier {
245a83710eSEric Fiselier std::vector<bool, test_allocator<bool> > l(test_allocator<bool>(5));
255a83710eSEric Fiselier std::vector<bool, test_allocator<bool> > lo(test_allocator<bool>(5));
265a83710eSEric Fiselier for (int i = 1; i <= 3; ++i)
275a83710eSEric Fiselier {
285a83710eSEric Fiselier l.push_back(i);
295a83710eSEric Fiselier lo.push_back(i);
305a83710eSEric Fiselier }
315a83710eSEric Fiselier std::vector<bool, test_allocator<bool> > l2(std::move(l), test_allocator<bool>(6));
325a83710eSEric Fiselier assert(l2 == lo);
335a83710eSEric Fiselier assert(!l.empty());
345a83710eSEric Fiselier assert(l2.get_allocator() == test_allocator<bool>(6));
355a83710eSEric Fiselier }
365a83710eSEric Fiselier {
375a83710eSEric Fiselier std::vector<bool, test_allocator<bool> > l(test_allocator<bool>(5));
385a83710eSEric Fiselier std::vector<bool, test_allocator<bool> > lo(test_allocator<bool>(5));
395a83710eSEric Fiselier for (int i = 1; i <= 3; ++i)
405a83710eSEric Fiselier {
415a83710eSEric Fiselier l.push_back(i);
425a83710eSEric Fiselier lo.push_back(i);
435a83710eSEric Fiselier }
445a83710eSEric Fiselier std::vector<bool, test_allocator<bool> > l2(std::move(l), test_allocator<bool>(5));
455a83710eSEric Fiselier assert(l2 == lo);
465a83710eSEric Fiselier assert(l.empty());
475a83710eSEric Fiselier assert(l2.get_allocator() == test_allocator<bool>(5));
485a83710eSEric Fiselier }
495a83710eSEric Fiselier {
505a83710eSEric Fiselier std::vector<bool, other_allocator<bool> > l(other_allocator<bool>(5));
515a83710eSEric Fiselier std::vector<bool, other_allocator<bool> > lo(other_allocator<bool>(5));
525a83710eSEric Fiselier for (int i = 1; i <= 3; ++i)
535a83710eSEric Fiselier {
545a83710eSEric Fiselier l.push_back(i);
555a83710eSEric Fiselier lo.push_back(i);
565a83710eSEric Fiselier }
575a83710eSEric Fiselier std::vector<bool, other_allocator<bool> > l2(std::move(l), other_allocator<bool>(4));
585a83710eSEric Fiselier assert(l2 == lo);
595a83710eSEric Fiselier assert(!l.empty());
605a83710eSEric Fiselier assert(l2.get_allocator() == other_allocator<bool>(4));
615a83710eSEric Fiselier }
625a83710eSEric Fiselier {
635a83710eSEric Fiselier std::vector<bool, min_allocator<bool> > l(min_allocator<bool>{});
645a83710eSEric Fiselier std::vector<bool, min_allocator<bool> > lo(min_allocator<bool>{});
655a83710eSEric Fiselier for (int i = 1; i <= 3; ++i)
665a83710eSEric Fiselier {
675a83710eSEric Fiselier l.push_back(i);
685a83710eSEric Fiselier lo.push_back(i);
695a83710eSEric Fiselier }
705a83710eSEric Fiselier std::vector<bool, min_allocator<bool> > l2(std::move(l), min_allocator<bool>());
715a83710eSEric Fiselier assert(l2 == lo);
725a83710eSEric Fiselier assert(l.empty());
735a83710eSEric Fiselier assert(l2.get_allocator() == min_allocator<bool>());
745a83710eSEric Fiselier }
752df59c50SJF Bastien
76*c74059c5SNikolas Klauser return true;
77*c74059c5SNikolas Klauser }
78*c74059c5SNikolas Klauser
main(int,char **)79*c74059c5SNikolas Klauser int main(int, char**)
80*c74059c5SNikolas Klauser {
81*c74059c5SNikolas Klauser tests();
82*c74059c5SNikolas Klauser #if TEST_STD_VER > 17
83*c74059c5SNikolas Klauser static_assert(tests());
84*c74059c5SNikolas Klauser #endif
852df59c50SJF Bastien return 0;
865a83710eSEric Fiselier }
87