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 // vector(const Alloc& = Alloc()); 13 14 #include <vector> 15 #include <cassert> 16 17 #include "test_allocator.h" 18 #include "../../../NotConstructible.h" 19 #include "../../../stack_allocator.h" 20 #include "min_allocator.h" 21 22 template <class C> 23 void 24 test0() 25 { 26 C c; 27 assert(c.__invariants()); 28 assert(c.empty()); 29 assert(c.get_allocator() == typename C::allocator_type()); 30 #if __cplusplus >= 201103L 31 C c1 = {}; 32 assert(c1.__invariants()); 33 assert(c1.empty()); 34 assert(c1.get_allocator() == typename C::allocator_type()); 35 #endif 36 } 37 38 template <class C> 39 void 40 test1(const typename C::allocator_type& a) 41 { 42 C c(a); 43 assert(c.__invariants()); 44 assert(c.empty()); 45 assert(c.get_allocator() == a); 46 } 47 48 int main() 49 { 50 { 51 test0<std::vector<int> >(); 52 test0<std::vector<NotConstructible> >(); 53 test1<std::vector<int, test_allocator<int> > >(test_allocator<int>(3)); 54 test1<std::vector<NotConstructible, test_allocator<NotConstructible> > > 55 (test_allocator<NotConstructible>(5)); 56 } 57 { 58 std::vector<int, stack_allocator<int, 10> > v; 59 assert(v.empty()); 60 } 61 #if __cplusplus >= 201103L 62 { 63 test0<std::vector<int, min_allocator<int>> >(); 64 test0<std::vector<NotConstructible, min_allocator<NotConstructible>> >(); 65 test1<std::vector<int, min_allocator<int> > >(min_allocator<int>{}); 66 test1<std::vector<NotConstructible, min_allocator<NotConstructible> > > 67 (min_allocator<NotConstructible>{}); 68 } 69 { 70 std::vector<int, min_allocator<int> > v; 71 assert(v.empty()); 72 } 73 #endif 74 } 75