libstdc++: Apply proposed resolution for LWG 3450

libstdc++-v3/ChangeLog:

	* include/std/ranges (take_while_view::begin): Constrain the
	const overload further as per LWG 3450.
	(take_while_view::end): Likewise.
	* testsuite/std/ranges/adaptors/take_while.cc: Add test for LWG
	3450.
This commit is contained in:
Patrick Palka 2020-10-12 13:46:24 -04:00
parent e066821b6f
commit c5aad5a418
2 changed files with 12 additions and 0 deletions

View File

@ -1888,6 +1888,7 @@ namespace views
constexpr auto
begin() const requires range<const _Vp>
&& indirect_unary_predicate<const _Pred, iterator_t<const _Vp>>
{ return ranges::begin(_M_base); }
constexpr auto
@ -1897,6 +1898,7 @@ namespace views
constexpr auto
end() const requires range<const _Vp>
&& indirect_unary_predicate<const _Pred, iterator_t<const _Vp>>
{ return _Sentinel<true>(ranges::end(_M_base),
std::__addressof(*_M_pred)); }
};

View File

@ -70,10 +70,20 @@ test03()
b = ranges::end(v);
}
void
test04()
{
// LWG 3450
auto v = views::single(1) | views::take_while([](int& x) { return true;});
static_assert(ranges::range<decltype(v)>);
static_assert(!ranges::range<decltype(v) const>);
}
int
main()
{
test01();
test02();
test03();
test04();
}