_M_equal(const _Iterator& __x) const
{ return __x._M_value == _M_bound; }
+ constexpr auto
+ _M_distance_from(const _Iterator& __x) const
+ { return _M_bound - __x._M_value; }
+
_Bound _M_bound = _Bound();
public:
friend constexpr iter_difference_t<_Winc>
operator-(const _Iterator& __x, const _Sentinel& __y)
requires sized_sentinel_for<_Bound, _Winc>
- { return __x._M_value - __y._M_bound; }
+ { return -__y._M_distance_from(__x); }
friend constexpr iter_difference_t<_Winc>
operator-(const _Sentinel& __x, const _Iterator& __y)
requires sized_sentinel_for<_Bound, _Winc>
- { return -(__y - __x); }
+ { return __x._M_distance_from(__y); }
};
_Winc _M_value = _Winc();
// Verify we optimize away the 'bound' data member of an unbounded iota_view.
static_assert(sizeof(std::ranges::iota_view<char>) == 1);
+void
+test05()
+{
+ // PR libstdc++/100690
+ int x[] = {42, 42, 42};
+ auto r = std::views::iota(std::ranges::begin(x), std::ranges::cbegin(x) + 3);
+ VERIFY( r.end() - r.begin() == 3 );
+ VERIFY( r.begin() - r.end() == -3 );
+}
+
int
main()
{
test02();
test03();
test04();
+ test05();
}