mirror of
git://gcc.gnu.org/git/gcc.git
synced 2025-04-09 03:00:27 +08:00
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:
parent
e066821b6f
commit
c5aad5a418
@ -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)); }
|
||||
};
|
||||
|
@ -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();
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user