From: Patrick Palka Date: Mon, 12 Oct 2020 17:46:24 +0000 (-0400) Subject: libstdc++: Apply proposed resolution for LWG 3450 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=c5aad5a41838dbfd29ff114692ff9533b52746b4;p=gcc.git 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. --- diff --git a/libstdc++-v3/include/std/ranges b/libstdc++-v3/include/std/ranges index 19bc01a3b3a..55e7c4de234 100644 --- a/libstdc++-v3/include/std/ranges +++ b/libstdc++-v3/include/std/ranges @@ -1888,6 +1888,7 @@ namespace views constexpr auto begin() const requires range + && indirect_unary_predicate> { return ranges::begin(_M_base); } constexpr auto @@ -1897,6 +1898,7 @@ namespace views constexpr auto end() const requires range + && indirect_unary_predicate> { return _Sentinel(ranges::end(_M_base), std::__addressof(*_M_pred)); } }; diff --git a/libstdc++-v3/testsuite/std/ranges/adaptors/take_while.cc b/libstdc++-v3/testsuite/std/ranges/adaptors/take_while.cc index d587127b97e..48771397f1d 100644 --- a/libstdc++-v3/testsuite/std/ranges/adaptors/take_while.cc +++ b/libstdc++-v3/testsuite/std/ranges/adaptors/take_while.cc @@ -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); + static_assert(!ranges::range); +} + int main() { test01(); test02(); test03(); + test04(); }