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// void resize(size_type sz);
13
14#include <vector>
15#include <cassert>
16#include "../../../stack_allocator.h"
17#include "../../../MoveOnly.h"
18#include "min_allocator.h"
19
20int main()
21{
22#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
23    {
24        std::vector<MoveOnly> v(100);
25        v.resize(50);
26        assert(v.size() == 50);
27        assert(v.capacity() == 100);
28        v.resize(200);
29        assert(v.size() == 200);
30        assert(v.capacity() >= 200);
31    }
32    {
33        std::vector<MoveOnly, stack_allocator<MoveOnly, 300> > v(100);
34        v.resize(50);
35        assert(v.size() == 50);
36        assert(v.capacity() == 100);
37        v.resize(200);
38        assert(v.size() == 200);
39        assert(v.capacity() >= 200);
40    }
41#else  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
42    {
43        std::vector<int> v(100);
44        v.resize(50);
45        assert(v.size() == 50);
46        assert(v.capacity() == 100);
47        v.resize(200);
48        assert(v.size() == 200);
49        assert(v.capacity() >= 200);
50    }
51    {
52        std::vector<int, stack_allocator<int, 300> > v(100);
53        v.resize(50);
54        assert(v.size() == 50);
55        assert(v.capacity() == 100);
56        v.resize(200);
57        assert(v.size() == 200);
58        assert(v.capacity() >= 200);
59    }
60#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
61#if __cplusplus >= 201103L
62    {
63        std::vector<MoveOnly, min_allocator<MoveOnly>> v(100);
64        v.resize(50);
65        assert(v.size() == 50);
66        assert(v.capacity() == 100);
67        v.resize(200);
68        assert(v.size() == 200);
69        assert(v.capacity() >= 200);
70    }
71#endif
72}
73