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 } 31 32 template <class C> 33 void 34 test1(const typename C::allocator_type& a) 35 { 36 C c(a); 37 assert(c.__invariants()); 38 assert(c.empty()); 39 assert(c.get_allocator() == a); 40 } 41 42 int main() 43 { 44 { 45 test0<std::vector<int> >(); 46 test0<std::vector<NotConstructible> >(); 47 test1<std::vector<int, test_allocator<int> > >(test_allocator<int>(3)); 48 test1<std::vector<NotConstructible, test_allocator<NotConstructible> > > 49 (test_allocator<NotConstructible>(5)); 50 } 51 { 52 std::vector<int, stack_allocator<int, 10> > v; 53 assert(v.empty()); 54 } 55 #if __cplusplus >= 201103L 56 { 57 test0<std::vector<int, min_allocator<int>> >(); 58 test0<std::vector<NotConstructible, min_allocator<NotConstructible>> >(); 59 test1<std::vector<int, min_allocator<int> > >(min_allocator<int>{}); 60 test1<std::vector<NotConstructible, min_allocator<NotConstructible> > > 61 (min_allocator<NotConstructible>{}); 62 } 63 { 64 std::vector<int, min_allocator<int> > v; 65 assert(v.empty()); 66 } 67 #endif 68 } 69