Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1 | //===----------------------------------------------------------------------===// |
| 2 | // |
Howard Hinnant | f5256e1 | 2010-05-11 21:36:01 +0000 | [diff] [blame] | 3 | // The LLVM Compiler Infrastructure |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4 | // |
| 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | |
| 10 | // <vector> |
| 11 | |
| 12 | // vector(vector&& c, const allocator_type& a); |
| 13 | |
| 14 | #include <vector> |
| 15 | #include <cassert> |
| 16 | #include "../../test_allocator.h" |
| 17 | |
| 18 | int main() |
| 19 | { |
Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame^] | 20 | #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 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(std::move(l), test_allocator<bool>(6)); |
| 30 | assert(l2 == lo); |
| 31 | assert(!l.empty()); |
| 32 | assert(l2.get_allocator() == test_allocator<bool>(6)); |
| 33 | } |
| 34 | { |
| 35 | std::vector<bool, test_allocator<bool> > l(test_allocator<bool>(5)); |
| 36 | std::vector<bool, test_allocator<bool> > lo(test_allocator<bool>(5)); |
| 37 | for (int i = 1; i <= 3; ++i) |
| 38 | { |
| 39 | l.push_back(i); |
| 40 | lo.push_back(i); |
| 41 | } |
| 42 | std::vector<bool, test_allocator<bool> > l2(std::move(l), test_allocator<bool>(5)); |
| 43 | assert(l2 == lo); |
| 44 | assert(l.empty()); |
| 45 | assert(l2.get_allocator() == test_allocator<bool>(5)); |
| 46 | } |
| 47 | { |
| 48 | std::vector<bool, other_allocator<bool> > l(other_allocator<bool>(5)); |
| 49 | std::vector<bool, other_allocator<bool> > lo(other_allocator<bool>(5)); |
| 50 | for (int i = 1; i <= 3; ++i) |
| 51 | { |
| 52 | l.push_back(i); |
| 53 | lo.push_back(i); |
| 54 | } |
| 55 | std::vector<bool, other_allocator<bool> > l2(std::move(l), other_allocator<bool>(4)); |
| 56 | assert(l2 == lo); |
| 57 | assert(!l.empty()); |
| 58 | assert(l2.get_allocator() == other_allocator<bool>(4)); |
| 59 | } |
Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame^] | 60 | #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 61 | } |