requires random_access_range<_Base>
{ return {*__i._M_parent, __i._M_current - __n}; }
+ // _GLIBCXX_RESOLVE_LIB_DEFECTS
+ // 3483. transform_view::iterator's difference is overconstrained
friend constexpr difference_type
operator-(const _Iterator& __x, const _Iterator& __y)
- requires random_access_range<_Base>
+ requires sized_sentinel_for<iterator_t<_Base>, iterator_t<_Base>>
{ return __x._M_current - __y._M_current; }
friend constexpr decltype(auto)
requires random_access_range<_Base>
{ return _Iterator{__x} -= __y; }
+ // _GLIBCXX_RESOLVE_LIB_DEFECTS
+ // 3483. transform_view::iterator's difference is overconstrained
friend constexpr difference_type
operator-(const _Iterator& __x, const _Iterator& __y)
- requires random_access_range<_Base>
+ requires sized_sentinel_for<iterator_t<_Base>, iterator_t<_Base>>
{ return __x._M_current - __y._M_current; }
friend _Sentinel<_Const>;
VERIFY( ranges::equal(v2, (std::pair<char, int>[]){{1,2}}) );
}
+struct X
+{
+ using Iter = __gnu_test::forward_iterator_wrapper<std::pair<int, X>>;
+
+ friend auto operator-(Iter l, Iter r) { return l.ptr - r.ptr; }
+};
+
+void
+test03()
+{
+ // LWG 3483
+ std::pair<int, X> x[3];
+ __gnu_test::test_forward_range<std::pair<int, X>> r(x);
+ auto v = views::elements<1>(r);
+ auto b = begin(v);
+ static_assert( !ranges::random_access_range<decltype(r)> );
+ static_assert( std::sized_sentinel_for<decltype(b), decltype(b)> );
+ VERIFY( (next(b, 1) - b) == 1 );
+ const auto v_const = v;
+ auto b_const = begin(v_const);
+ VERIFY( (next(b_const, 2) - b_const) == 2 );
+}
+
int
main()
{
test01();
test02();
+ test03();
}
b = ranges::end(v);
}
+struct Y
+{
+ using Iter = __gnu_test::forward_iterator_wrapper<Y>;
+
+ friend auto operator-(Iter l, Iter r) { return l.ptr - r.ptr; }
+};
+
+void
+test06()
+{
+ // LWG 3483
+ Y y[3];
+ __gnu_test::test_forward_range<Y> r(y);
+ auto v = views::transform(r, std::identity{});
+ auto b = begin(v);
+ static_assert( !ranges::random_access_range<decltype(r)> );
+ static_assert( std::sized_sentinel_for<decltype(b), decltype(b)> );
+ VERIFY( (next(b, 1) - b) == 1 );
+ const auto v_const = v;
+ auto b_const = begin(v_const);
+ VERIFY( (next(b_const, 2) - b_const) == 2 );
+}
+
int
main()
{
test03();
test04();
test05();
+ test06();
}