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& operator=(vector&& c); 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(test_allocator<bool>(5)); 31 l2 = std::move(l); 32 assert(l2 == lo); 33 assert(l.empty()); 34 assert(l2.get_allocator() == lo.get_allocator()); 35 } 36 { 37 std::vector<bool, test_allocator<bool> > l(test_allocator<bool>(5)); 38 std::vector<bool, test_allocator<bool> > lo(test_allocator<bool>(5)); 39 for (int i = 1; i <= 3; ++i) 40 { 41 l.push_back(i); 42 lo.push_back(i); 43 } 44 std::vector<bool, test_allocator<bool> > l2(test_allocator<bool>(6)); 45 l2 = std::move(l); 46 assert(l2 == lo); 47 assert(!l.empty()); 48 assert(l2.get_allocator() == test_allocator<bool>(6)); 49 } 50 { 51 std::vector<bool, other_allocator<bool> > l(other_allocator<bool>(5)); 52 std::vector<bool, other_allocator<bool> > lo(other_allocator<bool>(5)); 53 for (int i = 1; i <= 3; ++i) 54 { 55 l.push_back(i); 56 lo.push_back(i); 57 } 58 std::vector<bool, other_allocator<bool> > l2(other_allocator<bool>(6)); 59 l2 = std::move(l); 60 assert(l2 == lo); 61 assert(l.empty()); 62 assert(l2.get_allocator() == lo.get_allocator()); 63 } 64 { 65 std::vector<bool, min_allocator<bool> > l(min_allocator<bool>{}); 66 std::vector<bool, min_allocator<bool> > lo(min_allocator<bool>{}); 67 for (int i = 1; i <= 3; ++i) 68 { 69 l.push_back(i); 70 lo.push_back(i); 71 } 72 std::vector<bool, min_allocator<bool> > l2(min_allocator<bool>{}); 73 l2 = std::move(l); 74 assert(l2 == lo); 75 assert(l.empty()); 76 assert(l2.get_allocator() == lo.get_allocator()); 77 } 78 79 return 0; 80 } 81