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 // An vector is a contiguous container 13 14 #include <vector> 15 #include <cassert> 16 17 #include "test_allocator.h" 18 #include "min_allocator.h" 19 20 template <class C> 21 void test_contiguous ( const C &c ) 22 { 23 for ( size_t i = 0; i < c.size(); ++i ) 24 assert ( *(c.begin() + i) == *(std::addressof(*c.begin()) + i)); 25 } 26 27 int main() 28 { 29 { 30 typedef int T; 31 typedef std::vector<T> C; 32 test_contiguous(C()); 33 test_contiguous(C(3, 5)); 34 } 35 36 { 37 typedef double T; 38 typedef test_allocator<T> A; 39 typedef std::vector<T, A> C; 40 test_contiguous(C(A(3))); 41 test_contiguous(C(7, 9.0, A(5))); 42 } 43 #if __cplusplus >= 201103L 44 { 45 typedef double T; 46 typedef min_allocator<T> A; 47 typedef std::vector<T, A> C; 48 test_contiguous(C(A{})); 49 test_contiguous(C(9, 11.0, A{})); 50 } 51 #endif 52 } 53