blob: 5863e4497327f7b9a29a225dafcc674a48cb623e [file] [log] [blame]
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001//===----------------------------------------------------------------------===//
2//
Howard Hinnantf5256e12010-05-11 21:36:01 +00003// The LLVM Compiler Infrastructure
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00004//
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
19int main()
20{
Howard Hinnant73d21a42010-09-04 23:28:19 +000021#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
Howard Hinnantbc8d3f92010-05-11 19:42:16 +000022 {
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 Hinnant73d21a42010-09-04 23:28:19 +000040#else // _LIBCPP_HAS_NO_RVALUE_REFERENCES
Howard Hinnantbc8d3f92010-05-11 19:42:16 +000041 {
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 Hinnant73d21a42010-09-04 23:28:19 +000059#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
Howard Hinnantbc8d3f92010-05-11 19:42:16 +000060}