requires sized_sentinel_for<iterator_t<_Base>, iterator_t<_Base>>
{ return __x._M_current - __y._M_current; }
- friend _Sentinel<_Const>;
+ template <bool> friend struct _Sentinel;
};
template<bool _Const>
struct _Sentinel
{
private:
- constexpr bool
- _M_equal(const _Iterator<_Const>& __x) const
- { return __x._M_current == _M_end; }
+ template<bool _Const2>
+ constexpr bool
+ _M_equal(const _Iterator<_Const2>& __x) const
+ { return __x._M_current == _M_end; }
+
+ template<bool _Const2>
+ constexpr auto
+ _M_distance_from(const _Iterator<_Const2>& __i) const
+ { return _M_end - __i._M_current; }
using _Base = elements_view::_Base<_Const>;
sentinel_t<_Base> _M_end = sentinel_t<_Base>();
template<bool _Const2,
typename _Base2 = __detail::__maybe_const_t<_Const2, _Vp>>
requires sized_sentinel_for<sentinel_t<_Base>, iterator_t<_Base2>>
- friend constexpr range_difference_t<_Base>
+ friend constexpr range_difference_t<_Base2>
operator-(const _Sentinel& __x, const _Iterator<_Const2>& __y)
- { return __x._M_end - __y._M_current; }
+ { return __x._M_distance_from(__y); }
friend _Sentinel<!_Const>;
};
VERIFY( r2[0] == 1 && r2[1] == 3 );
}
+void
+test06()
+{
+ // PR libstdc++/100631
+ auto r = views::iota(0)
+ | views::filter([](int){ return true; })
+ | views::take(42)
+ | views::reverse
+ | views::transform([](int) { return std::make_pair(42, "hello"); })
+ | views::take(42)
+ | views::keys;
+ auto b = r.begin();
+ auto e = r.end();
+ e - b;
+}
+
+void
+test07()
+{
+ // PR libstdc++/100631 comment #2
+ auto r = views::iota(0)
+ | views::transform([](int) { return std::make_pair(42, "hello"); })
+ | views::keys;
+ auto b = ranges::cbegin(r);
+ auto e = ranges::end(r);
+ b.base() == e.base();
+ b == e;
+}
+
int
main()
{
test03();
test04();
test05();
+ test06();
+ test07();
}