File tree Expand file tree Collapse file tree 1 file changed +37
-0
lines changed
libcxx/test/std/ranges/range.adaptors/range.concat/iterator Expand file tree Collapse file tree 1 file changed +37
-0
lines changed Original file line number Diff line number Diff line change @@ -122,6 +122,43 @@ constexpr bool test() {
122122 static_assert (!CanDecrement<Iter>);
123123 }
124124
125+ // Cross-boundary decrement: from begin of a later range into the previous range's last element.
126+ {
127+ auto v = std::views::concat (a, b);
128+
129+ // Position at the first element of `b`, then -- to land on a.back().
130+ auto it = v.begin ();
131+ it += a.size ();
132+ --it;
133+ assert (*it == a.back ());
134+
135+ // Post-decrement variant from b[0]; result is old iterator, `it2` moves to a.back().
136+ auto it2 = v.begin ();
137+ it2 += a.size ();
138+ auto old = it2--;
139+ static_assert (std::is_same_v<decltype (old), decltype (it2)>);
140+ assert (*old == b.front ());
141+ assert (*it2 == a.back ());
142+ }
143+
144+ // Cross-boundary with three ranges
145+ {
146+ std::array<int , 3 > c{9 , 10 , 11 };
147+ auto v3 = std::views::concat (a, b, c);
148+
149+ auto it = v3.begin ();
150+ it += a.size () + b.size ();
151+ --it;
152+ assert (*it == b.back ());
153+
154+ // const-iterator.
155+ const auto & cv3 = v3;
156+ auto cit = cv3.begin ();
157+ cit += a.size () + b.size ();
158+ --cit;
159+ assert (*cit == b.back ());
160+ }
161+
125162 return true ;
126163}
127164
You can’t perform that action at this time.
0 commit comments