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 // iterator begin();
12 // iterator end();
13 // const_iterator begin() const;
14 // const_iterator end() const;
15 // const_iterator cbegin() const;
16 // const_iterator cend() const;
17
18 #include <vector>
19 #include <cassert>
20 #include <iterator>
21
22 #include "test_macros.h"
23 #include "min_allocator.h"
24
main(int,char **)25 int main(int, char**)
26 {
27 {
28 typedef bool T;
29 typedef std::vector<T> C;
30 C c;
31 C::iterator i = c.begin();
32 C::iterator j = c.end();
33 assert(std::distance(i, j) == 0);
34 assert(i == j);
35 }
36 {
37 typedef bool T;
38 typedef std::vector<T> C;
39 const C c;
40 C::const_iterator i = c.begin();
41 C::const_iterator j = c.end();
42 assert(std::distance(i, j) == 0);
43 assert(i == j);
44 }
45 {
46 typedef bool T;
47 typedef std::vector<T> C;
48 C c;
49 C::const_iterator i = c.cbegin();
50 C::const_iterator j = c.cend();
51 assert(std::distance(i, j) == 0);
52 assert(i == j);
53 assert(i == c.end());
54 }
55 {
56 typedef bool T;
57 typedef std::vector<T> C;
58 C::iterator i;
59 C::const_iterator j;
60 }
61 #if TEST_STD_VER >= 11
62 {
63 typedef bool T;
64 typedef std::vector<T, min_allocator<T>> C;
65 C c;
66 C::iterator i = c.begin();
67 C::iterator j = c.end();
68 assert(std::distance(i, j) == 0);
69 assert(i == j);
70 }
71 {
72 typedef bool T;
73 typedef std::vector<T, min_allocator<T>> C;
74 const C c;
75 C::const_iterator i = c.begin();
76 C::const_iterator j = c.end();
77 assert(std::distance(i, j) == 0);
78 assert(i == j);
79 }
80 {
81 typedef bool T;
82 typedef std::vector<T, min_allocator<T>> C;
83 C c;
84 C::const_iterator i = c.cbegin();
85 C::const_iterator j = c.cend();
86 assert(std::distance(i, j) == 0);
87 assert(i == j);
88 assert(i == c.end());
89 }
90 {
91 typedef bool T;
92 typedef std::vector<T, min_allocator<T>> C;
93 C::iterator i;
94 C::const_iterator j;
95 }
96 #endif
97 #if TEST_STD_VER > 11
98 { // N3644 testing
99 std::vector<bool>::iterator ii1{}, ii2{};
100 std::vector<bool>::iterator ii4 = ii1;
101 std::vector<bool>::const_iterator cii{};
102 assert ( ii1 == ii2 );
103 assert ( ii1 == ii4 );
104
105 assert (!(ii1 != ii2 ));
106
107 assert ( (ii1 == cii ));
108 assert ( (cii == ii1 ));
109 assert (!(ii1 != cii ));
110 assert (!(cii != ii1 ));
111 assert (!(ii1 < cii ));
112 assert (!(cii < ii1 ));
113 assert ( (ii1 <= cii ));
114 assert ( (cii <= ii1 ));
115 assert (!(ii1 > cii ));
116 assert (!(cii > ii1 ));
117 assert ( (ii1 >= cii ));
118 assert ( (cii >= ii1 ));
119 assert (cii - ii1 == 0);
120 assert (ii1 - cii == 0);
121 }
122 #endif
123
124 return 0;
125 }
126