1 //===----------------------------------------------------------------------===//
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
7 //===----------------------------------------------------------------------===//
13 // const_iterator begin() const;
14 // const_iterator end() const;
15 // const_iterator cbegin() const;
16 // const_iterator cend() const;
22 #include "test_macros.h"
23 #include "min_allocator.h"
35 typedef std::vector
<T
> C
;
37 C::iterator i
= c
.begin();
38 C::iterator j
= c
.end();
39 assert(std::distance(i
, j
) == 0);
44 typedef std::vector
<T
> C
;
46 C::const_iterator i
= c
.begin();
47 C::const_iterator j
= c
.end();
48 assert(std::distance(i
, j
) == 0);
53 typedef std::vector
<T
> C
;
55 C::const_iterator i
= c
.cbegin();
56 C::const_iterator j
= c
.cend();
57 assert(std::distance(i
, j
) == 0);
63 typedef std::vector
<T
> C
;
64 const T t
[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
65 C
c(std::begin(t
), std::end(t
));
66 C::iterator i
= c
.begin();
72 assert(std::distance(c
.begin(), c
.end()) == 10);
76 typedef std::vector
<T
> C
;
82 #if TEST_STD_VER >= 11
85 typedef std::vector
<T
, min_allocator
<T
>> C
;
87 C::iterator i
= c
.begin();
88 C::iterator j
= c
.end();
89 assert(std::distance(i
, j
) == 0);
94 typedef std::vector
<T
, min_allocator
<T
>> C
;
96 C::const_iterator i
= c
.begin();
97 C::const_iterator j
= c
.end();
98 assert(std::distance(i
, j
) == 0);
103 typedef std::vector
<T
, min_allocator
<T
>> C
;
105 C::const_iterator i
= c
.cbegin();
106 C::const_iterator j
= c
.cend();
107 assert(std::distance(i
, j
) == 0);
109 assert(i
== c
.end());
113 typedef std::vector
<T
, min_allocator
<T
>> C
;
114 const T t
[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
115 C
c(std::begin(t
), std::end(t
));
116 C::iterator i
= c
.begin();
122 assert(std::distance(c
.begin(), c
.end()) == 10);
126 typedef std::vector
<T
, min_allocator
<T
>> C
;
134 typedef std::vector
<T
, min_allocator
<T
>> C
;
136 C::iterator i
= c
.begin();
138 C::const_iterator j
= i
;
139 assert(j
->first
== 3);
142 #if TEST_STD_VER > 11
144 typedef std::vector
<int> C
;
145 C::iterator ii1
{}, ii2
{};
146 C::iterator ii4
= ii1
;
147 C::const_iterator cii
{};
148 assert ( ii1
== ii2
);
149 assert ( ii1
== ii4
);
151 assert (!(ii1
!= ii2
));
153 assert ( (ii1
== cii
));
154 assert ( (cii
== ii1
));
155 assert (!(ii1
!= cii
));
156 assert (!(cii
!= ii1
));
157 assert (!(ii1
< cii
));
158 assert (!(cii
< ii1
));
159 assert ( (ii1
<= cii
));
160 assert ( (cii
<= ii1
));
161 assert (!(ii1
> cii
));
162 assert (!(cii
> ii1
));
163 assert ( (ii1
>= cii
));
164 assert ( (cii
>= ii1
));
165 assert (cii
- ii1
== 0);
166 assert (ii1
- cii
== 0);