Skip to content

Commit 8b6a060

Browse files
decrement
1 parent 7413258 commit 8b6a060

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

libcxx/test/std/ranges/range.adaptors/range.concat/iterator/decrement.pass.cpp

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff 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

0 commit comments

Comments
 (0)