1212// constexpr iterator<true > begin() const requires (range<const First> && ... && range<const Vs>);
1313
1414#include < ranges>
15-
16- // #include <cassert>
17- // #include <concepts>
18- // #include <tuple>
19- // #include <utility>
15+ #include < cassert>
16+ #include < concepts>
17+ #include < tuple>
18+ #include < utility>
2019
2120#include " types.h"
2221
@@ -27,17 +26,17 @@ template <class T>
2726concept HasNonConstBegin = requires (T& t) { t.begin (); };
2827
2928template <class T >
30- concept HasConstAndNonConstBegin =
31- HasConstBegin<T> && HasNonConstBegin<T> &&
32- requires (T& t, const T& ct) { requires !std::same_as< decltype (t. begin ()), decltype (ct. begin ())>; };
29+ concept HasConstAndNonConstBegin = HasConstBegin<T> && HasNonConstBegin<T> && requires (T& t, const T& ct) {
30+ requires !std::same_as< decltype (t. begin ()), decltype (ct. begin ())>;
31+ };
3332
3433template <class T >
3534concept HasOnlyNonConstBegin = HasNonConstBegin<T> && !HasConstBegin<T>;
3635
3736template <class T >
3837concept HasOnlyConstBegin = HasConstBegin<T> && !HasConstAndNonConstBegin<T>;
3938
40- struct OnlyNonConstBeginView : std::ranges::view_base {
39+ struct NoConstBeginView : std::ranges::view_base {
4140 int * begin ();
4241 int * end ();
4342};
@@ -73,8 +72,7 @@ constexpr bool test() {
7372 }
7473 }
7574
76- {
77- // underlying ranges all model simple-view
75+ { // underlying ranges all model simple-view
7876 std::ranges::cartesian_product_view v (SimpleCommon{buffer}, SimpleCommon{buffer});
7977 static_assert (std::is_same_v<decltype (v.begin ()), decltype (std::as_const (v).begin ())>);
8078 assert (v.begin () == std::as_const (v).begin ());
@@ -89,28 +87,26 @@ constexpr bool test() {
8987 static_assert (!HasConstAndNonConstBegin<View>);
9088 }
9189
92- // {
93- // // not all underlying ranges model simple-view
94- // std::ranges::zip_view v(SimpleCommon{buffer}, NonSimpleNonCommon{buffer});
95- // static_assert(!std::is_same_v<decltype(v.begin()), decltype(std::as_const(v).begin())>);
96- // assert(v.begin() == std::as_const(v).begin());
97- // auto [x, y] = *std::as_const(v).begin();
98- // assert(&x == &buffer[0]);
99- // assert(&y == &buffer[0]);
100-
101- // using View = decltype(v);
102- // static_assert(!HasOnlyConstBegin<View>);
103- // static_assert(!HasOnlyNonConstBegin<View>);
104- // static_assert(HasConstAndNonConstBegin<View>);
105- // }
106-
107- // {
108- // // underlying const R is not a range
109- // using View = std::ranges::zip_view<SimpleCommon, NoConstBeginView>;
110- // static_assert(!HasOnlyConstBegin<View>);
111- // static_assert(HasOnlyNonConstBegin<View>);
112- // static_assert(!HasConstAndNonConstBegin<View>);
113- // }
90+ { // not all underlying ranges model simple-view
91+ std::ranges::cartesian_product_view v (SimpleCommon{buffer}, NonSimpleNonCommon{buffer});
92+ static_assert (!std::is_same_v<decltype (v.begin ()), decltype (std::as_const (v).begin ())>);
93+ assert (v.begin () == std::as_const (v).begin ());
94+ auto [x, y] = *std::as_const (v).begin ();
95+ assert (&x == &buffer[0 ]);
96+ assert (&y == &buffer[0 ]);
97+
98+ using View = decltype (v);
99+ static_assert (!HasOnlyConstBegin<View>);
100+ static_assert (!HasOnlyNonConstBegin<View>);
101+ static_assert (HasConstAndNonConstBegin<View>);
102+ }
103+
104+ { // underlying const R is not a range
105+ using View = std::ranges::cartesian_product_view<SimpleCommon, NoConstBeginView>;
106+ static_assert (!HasOnlyConstBegin<View>);
107+ static_assert (HasOnlyNonConstBegin<View>);
108+ static_assert (!HasConstAndNonConstBegin<View>);
109+ }
114110 return true ;
115111}
116112
0 commit comments