File tree Expand file tree Collapse file tree 1 file changed +35
-0
lines changed
libcxx/test/std/ranges/range.adaptors/range.concat/iterator Expand file tree Collapse file tree 1 file changed +35
-0
lines changed Original file line number Diff line number Diff line change @@ -159,6 +159,41 @@ constexpr bool test() {
159159 assert (*cit == b.back ());
160160 }
161161
162+ // Cross-boundary decrement where the previous range is empty.
163+ {
164+ std::array<int , 0 > e{};
165+ auto v = std::views::concat (a, e, b);
166+
167+ auto it = v.begin ();
168+ it += a.size (); // points at beginning of b
169+ --it; // this skips e
170+ assert (*it == a.back ());
171+
172+ auto it2 = v.begin ();
173+ it2 += a.size ();
174+ auto old = it2--;
175+ assert (*old == b.front ());
176+ assert (*it2 == a.back ());
177+
178+ // const-iterator
179+ const auto & cv = v;
180+ auto cit = cv.begin ();
181+ cit += a.size ();
182+ --cit;
183+ assert (*cit == a.back ());
184+ }
185+
186+ // multiple empty ranges in the middle
187+ {
188+ std::array<int , 0 > e1 {}, e2 {};
189+ auto v = std::views::concat (a, e1 , e2 , b);
190+
191+ auto it = v.begin ();
192+ it += a.size (); // points to b[0]
193+ --it; // skip e2 and e1
194+ assert (*it == a.back ());
195+ }
196+
162197 return true ;
163198}
164199
You can’t perform that action at this time.
0 commit comments