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 // UNSUPPORTED: c++98, c++03 11 12 // <vector> 13 14 // vector(vector&& c); 15 16 #include <vector> 17 #include <cassert> 18 #include "test_allocator.h" 19 #include "min_allocator.h" 20 21 int main() 22 { 23 { 24 std::vector<bool, test_allocator<bool> > l(test_allocator<bool>(5)); 25 std::vector<bool, test_allocator<bool> > lo(test_allocator<bool>(5)); 26 for (int i = 1; i <= 3; ++i) 27 { 28 l.push_back(i); 29 lo.push_back(i); 30 } 31 std::vector<bool, test_allocator<bool> > 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, other_allocator<bool> > l(other_allocator<bool>(5)); 38 std::vector<bool, other_allocator<bool> > lo(other_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, other_allocator<bool> > l2 = std::move(l); 45 assert(l2 == lo); 46 assert(l.empty()); 47 assert(l2.get_allocator() == lo.get_allocator()); 48 } 49 { 50 std::vector<bool, min_allocator<bool> > l(min_allocator<bool>{}); 51 std::vector<bool, min_allocator<bool> > lo(min_allocator<bool>{}); 52 for (int i = 1; i <= 3; ++i) 53 { 54 l.push_back(i); 55 lo.push_back(i); 56 } 57 std::vector<bool, min_allocator<bool> > l2 = std::move(l); 58 assert(l2 == lo); 59 assert(l.empty()); 60 assert(l2.get_allocator() == lo.get_allocator()); 61 } 62 } 63