1 //===----------------------------------------------------------------------===// 2 // 3 // The LLVM Compiler Infrastructure 4 // 5 // This file is dual licensed under the MIT and the University of Illinois Open 6 // Source Licenses. See LICENSE.TXT for details. 7 // 8 //===----------------------------------------------------------------------===// 9 10 // <vector> 11 12 // vector& operator=(vector&& c); 13 14 #include <vector> 15 #include <cassert> 16 #include "../../test_allocator.h" 17 18 int main() 19 { 20 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 21 { 22 std::vector<bool, test_allocator<bool> > l(test_allocator<bool>(5)); 23 std::vector<bool, test_allocator<bool> > lo(test_allocator<bool>(5)); 24 for (int i = 1; i <= 3; ++i) 25 { 26 l.push_back(i); 27 lo.push_back(i); 28 } 29 std::vector<bool, test_allocator<bool> > l2(test_allocator<bool>(5)); 30 l2 = std::move(l); 31 assert(l2 == lo); 32 assert(l.empty()); 33 assert(l2.get_allocator() == lo.get_allocator()); 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(test_allocator<bool>(6)); 44 l2 = std::move(l); 45 assert(l2 == lo); 46 assert(!l.empty()); 47 assert(l2.get_allocator() == test_allocator<bool>(6)); 48 } 49 { 50 std::vector<bool, other_allocator<bool> > l(other_allocator<bool>(5)); 51 std::vector<bool, other_allocator<bool> > lo(other_allocator<bool>(5)); 52 for (int i = 1; i <= 3; ++i) 53 { 54 l.push_back(i); 55 lo.push_back(i); 56 } 57 std::vector<bool, other_allocator<bool> > l2(other_allocator<bool>(6)); 58 l2 = std::move(l); 59 assert(l2 == lo); 60 assert(l.empty()); 61 assert(l2.get_allocator() == lo.get_allocator()); 62 } 63 #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES 64 } 65