1 //===----------------------------------------------------------------------===// 2 // 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 6 // 7 //===----------------------------------------------------------------------===// 8 9 // UNSUPPORTED: c++98, c++03 10 11 // <vector> 12 13 // vector(vector&& c, const allocator_type& a); 14 15 #include <vector> 16 #include <cassert> 17 #include "test_allocator.h" 18 #include "min_allocator.h" 19 20 int main(int, char**) 21 { 22 { 23 std::vector<bool, test_allocator<bool> > l(test_allocator<bool>(5)); 24 std::vector<bool, test_allocator<bool> > lo(test_allocator<bool>(5)); 25 for (int i = 1; i <= 3; ++i) 26 { 27 l.push_back(i); 28 lo.push_back(i); 29 } 30 std::vector<bool, test_allocator<bool> > l2(std::move(l), test_allocator<bool>(6)); 31 assert(l2 == lo); 32 assert(!l.empty()); 33 assert(l2.get_allocator() == test_allocator<bool>(6)); 34 } 35 { 36 std::vector<bool, test_allocator<bool> > l(test_allocator<bool>(5)); 37 std::vector<bool, test_allocator<bool> > lo(test_allocator<bool>(5)); 38 for (int i = 1; i <= 3; ++i) 39 { 40 l.push_back(i); 41 lo.push_back(i); 42 } 43 std::vector<bool, test_allocator<bool> > l2(std::move(l), test_allocator<bool>(5)); 44 assert(l2 == lo); 45 assert(l.empty()); 46 assert(l2.get_allocator() == test_allocator<bool>(5)); 47 } 48 { 49 std::vector<bool, other_allocator<bool> > l(other_allocator<bool>(5)); 50 std::vector<bool, other_allocator<bool> > lo(other_allocator<bool>(5)); 51 for (int i = 1; i <= 3; ++i) 52 { 53 l.push_back(i); 54 lo.push_back(i); 55 } 56 std::vector<bool, other_allocator<bool> > l2(std::move(l), other_allocator<bool>(4)); 57 assert(l2 == lo); 58 assert(!l.empty()); 59 assert(l2.get_allocator() == other_allocator<bool>(4)); 60 } 61 { 62 std::vector<bool, min_allocator<bool> > l(min_allocator<bool>{}); 63 std::vector<bool, min_allocator<bool> > lo(min_allocator<bool>{}); 64 for (int i = 1; i <= 3; ++i) 65 { 66 l.push_back(i); 67 lo.push_back(i); 68 } 69 std::vector<bool, min_allocator<bool> > l2(std::move(l), min_allocator<bool>()); 70 assert(l2 == lo); 71 assert(l.empty()); 72 assert(l2.get_allocator() == min_allocator<bool>()); 73 } 74 75 return 0; 76 } 77