Skip to content

Commit 370613d

Browse files
committed
test view::begin() cleanup
1 parent e5ebd79 commit 370613d

File tree

1 file changed

+14
-24
lines changed
  • libcxx/test/std/ranges/range.adaptors/range.cartesian.product.view

1 file changed

+14
-24
lines changed

libcxx/test/std/ranges/range.adaptors/range.cartesian.product.view/begin.pass.cpp

Lines changed: 14 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -44,32 +44,22 @@ struct NoConstBeginView : std::ranges::view_base {
4444
constexpr bool test() {
4545
int buffer[8] = {1, 2, 3, 4, 5, 6, 7, 8};
4646

47-
{ // all underlying iterators should be at the begin position
48-
{ // non-const
49-
std::ranges::cartesian_product_view v(
50-
SizedRandomAccessView{buffer}, std::views::iota(0), std::ranges::single_view(2.0));
51-
std::same_as<std::tuple<int&, int, double&>> decltype(auto) val = *v.begin();
52-
assert(val == std::make_tuple(1, 0, 2.0));
53-
assert(&(std::get<0>(val)) == &buffer[0]);
54-
}
55-
{ // const
56-
const std::ranges::cartesian_product_view v(
57-
SizedRandomAccessView{buffer}, std::views::iota(0), std::ranges::single_view(2.0));
58-
std::same_as<std::tuple<int&, int, const double&>> decltype(auto) val = *v.begin();
59-
assert(val == std::make_tuple(1, 0, 2.0));
60-
assert(&(std::get<0>(val)) == &buffer[0]);
61-
}
47+
{ // all underlying iterators should be at the begin position
48+
std::ranges::cartesian_product_view v(
49+
SizedRandomAccessView{buffer}, std::views::iota(0), std::ranges::single_view(2.0));
50+
std::same_as<std::tuple<int&, int, double&>> decltype(auto) mutVal = *v.begin();
51+
std::same_as<std::tuple<int&, int, const double&>> decltype(auto) constVal =
52+
*std::as_const(v).begin();
53+
assert(mutVal == std::make_tuple(1, 0, 2.0));
54+
assert(constVal == std::make_tuple(1, 0, 2.0));
55+
assert(&(std::get<0>(mutVal)) == &buffer[0]);
56+
assert(&(std::get<0>(constVal)) == &buffer[0]);
6257
}
6358

64-
{ // with empty range
65-
{ // non-const
66-
std::ranges::cartesian_product_view v(SizedRandomAccessView{buffer}, std::ranges::empty_view<int>());
67-
assert(v.begin() == v.end());
68-
}
69-
{ // const
70-
const std::ranges::cartesian_product_view v(SizedRandomAccessView{buffer}, std::ranges::empty_view<int>());
71-
assert(v.begin() == v.end());
72-
}
59+
{ // with empty range
60+
std::ranges::cartesian_product_view v(SizedRandomAccessView{buffer}, std::ranges::empty_view<int>());
61+
assert(v.begin() == v.end());
62+
assert(std::as_const(v).begin() == std::as_const(v).end());
7363
}
7464

7565
{ // underlying ranges all model simple-view

0 commit comments

Comments
 (0)