1 //===----------------------------------------------------------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
9 // <vector>
10 
11 // An vector is a contiguous container
12 
13 #include <vector>
14 #include <cassert>
15 
16 #include "test_allocator.h"
17 #include "min_allocator.h"
18 
19 template <class C>
20 void test_contiguous ( const C &c )
21 {
22     for ( size_t i = 0; i < c.size(); ++i )
23         assert ( *(c.begin() + static_cast<typename C::difference_type>(i)) == *(std::addressof(*c.begin()) + i));
24 }
25 
26 int main(int, char**)
27 {
28     {
29     typedef int T;
30     typedef std::vector<T> C;
31     test_contiguous(C());
32     test_contiguous(C(3, 5));
33     }
34 
35     {
36     typedef double T;
37     typedef test_allocator<T> A;
38     typedef std::vector<T, A> C;
39     test_contiguous(C(A(3)));
40     test_contiguous(C(7, 9.0, A(5)));
41     }
42 #if TEST_STD_VER >= 11
43     {
44     typedef double T;
45     typedef min_allocator<T> A;
46     typedef std::vector<T, A> C;
47     test_contiguous(C(A{}));
48     test_contiguous(C(9, 11.0, A{}));
49     }
50 #endif
51 
52   return 0;
53 }
54