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 reserve(size_type n); 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; 23 v.reserve(10); 24 assert(v.capacity() >= 10); 25 } 26 { 27 std::vector<int> v(100); 28 assert(v.capacity() == 100); 29 v.reserve(50); 30 assert(v.size() == 100); 31 assert(v.capacity() == 100); 32 v.reserve(150); 33 assert(v.size() == 100); 34 assert(v.capacity() == 150); 35 } 36 { 37 std::vector<int, stack_allocator<int, 250> > v(100); 38 assert(v.capacity() == 100); 39 v.reserve(50); 40 assert(v.size() == 100); 41 assert(v.capacity() == 100); 42 v.reserve(150); 43 assert(v.size() == 100); 44 assert(v.capacity() == 150); 45 } 46 #if __cplusplus >= 201103L 47 { 48 std::vector<int, min_allocator<int>> v; 49 v.reserve(10); 50 assert(v.capacity() >= 10); 51 } 52 { 53 std::vector<int, min_allocator<int>> v(100); 54 assert(v.capacity() == 100); 55 v.reserve(50); 56 assert(v.size() == 100); 57 assert(v.capacity() == 100); 58 v.reserve(150); 59 assert(v.size() == 100); 60 assert(v.capacity() == 150); 61 } 62 #endif 63 } 64