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 | // void resize(size_type sz); |
| 13 | |
| 14 | #include <vector> |
| 15 | #include <cassert> |
| 16 | #include "../../../stack_allocator.h" |
| 17 | #include "../../../MoveOnly.h" |
| 18 | |
| 19 | int main() |
| 20 | { |
Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame^] | 21 | #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 22 | { |
| 23 | std::vector<MoveOnly> v(100); |
| 24 | v.resize(50); |
| 25 | assert(v.size() == 50); |
| 26 | assert(v.capacity() == 100); |
| 27 | v.resize(200); |
| 28 | assert(v.size() == 200); |
| 29 | assert(v.capacity() >= 200); |
| 30 | } |
| 31 | { |
| 32 | std::vector<MoveOnly, stack_allocator<MoveOnly, 300> > v(100); |
| 33 | v.resize(50); |
| 34 | assert(v.size() == 50); |
| 35 | assert(v.capacity() == 100); |
| 36 | v.resize(200); |
| 37 | assert(v.size() == 200); |
| 38 | assert(v.capacity() >= 200); |
| 39 | } |
Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame^] | 40 | #else // _LIBCPP_HAS_NO_RVALUE_REFERENCES |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 41 | { |
| 42 | std::vector<int> v(100); |
| 43 | v.resize(50); |
| 44 | assert(v.size() == 50); |
| 45 | assert(v.capacity() == 100); |
| 46 | v.resize(200); |
| 47 | assert(v.size() == 200); |
| 48 | assert(v.capacity() >= 200); |
| 49 | } |
| 50 | { |
| 51 | std::vector<int, stack_allocator<int, 300> > v(100); |
| 52 | v.resize(50); |
| 53 | assert(v.size() == 50); |
| 54 | assert(v.capacity() == 100); |
| 55 | v.resize(200); |
| 56 | assert(v.size() == 200); |
| 57 | assert(v.capacity() >= 200); |
| 58 | } |
Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame^] | 59 | #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 60 | } |