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