private:
_Winc _M_value = _Winc();
+ friend iota_view;
friend _Sentinel;
};
operator-(const _Sentinel& __x, const _Iterator& __y)
requires sized_sentinel_for<_Bound, _Winc>
{ return __x._M_distance_from(__y); }
+
+ friend iota_view;
};
_Winc _M_value = _Winc();
__glibcxx_assert( bool(__value <= __bound) );
}
+ constexpr
+ iota_view(_Iterator __first, _Iterator __last)
+ requires same_as<_Winc, _Bound>
+ : iota_view(__first._M_value, __last._M_value)
+ { }
+
+ constexpr
+ iota_view(_Iterator __first, unreachable_sentinel_t __last)
+ requires same_as<_Bound, unreachable_sentinel_t>
+ : iota_view(__first._M_value, __last)
+ { }
+
+ constexpr
+ iota_view(_Iterator __first, _Sentinel __last)
+ requires (!same_as<_Winc, _Bound>) && (!same_as<_Bound, unreachable_sentinel_t>)
+ : iota_view(__first._M_value, __last._M_bound)
+ { }
+
constexpr _Iterator
begin() const { return _Iterator{_M_value}; }
// { dg-options "-std=gnu++2a" }
// { dg-do run { target c++2a } }
+#include <algorithm>
#include <ranges>
#include <testsuite_hooks.h>
VERIFY( r.begin() - r.end() == -3 );
}
+void
+test06()
+{
+ // Verify LWG 3523 changes.
+ auto v1 = std::views::iota(0, 5);
+ auto w1 = decltype(v1)(v1.begin(), v1.end());
+ VERIFY( std::ranges::equal(v1, w1) );
+
+ auto v2 = std::views::iota(0);
+ auto w2 = decltype(v2)(v2.begin(), v2.end());
+ static_assert(std::same_as<decltype(w2.end()), std::unreachable_sentinel_t>);
+ VERIFY( *w2.begin() == 0 );
+
+ auto v3 = std::views::iota(0, 5l);
+ auto w3 = decltype(v3)(v3.begin(), v3.end());
+ static_assert(!std::ranges::common_range<decltype(w3)>);
+ VERIFY( std::ranges::equal(v3, w3) );
+}
+
int
main()
{
test03();
test04();
test05();
+ test06();
}