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 shrink_to_fit();
13 
14 #include <vector>
15 #include <cassert>
16 #include "../../../stack_allocator.h"
17 #include "../../../min_allocator.h"
18 
19 int main()
20 {
21     {
22         std::vector<int> v(100);
23         v.push_back(1);
24         v.shrink_to_fit();
25         assert(v.capacity() == 101);
26         assert(v.size() == 101);
27     }
28     {
29         std::vector<int, stack_allocator<int, 401> > v(100);
30         v.push_back(1);
31         v.shrink_to_fit();
32         assert(v.capacity() == 101);
33         assert(v.size() == 101);
34     }
35 #ifndef _LIBCPP_NO_EXCEPTIONS
36     {
37         std::vector<int, stack_allocator<int, 400> > v(100);
38         v.push_back(1);
39         v.shrink_to_fit();
40         assert(v.capacity() == 200);
41         assert(v.size() == 101);
42     }
43 #endif
44 #if __cplusplus >= 201103L
45     {
46         std::vector<int, min_allocator<int>> v(100);
47         v.push_back(1);
48         v.shrink_to_fit();
49         assert(v.capacity() == 101);
50         assert(v.size() == 101);
51     }
52 #endif
53 }
54