]> gcc.gnu.org Git - gcc.git/commitdiff
libstdc++: Apply proposed resolution for LWG 3450
authorPatrick Palka <ppalka@redhat.com>
Mon, 12 Oct 2020 17:46:24 +0000 (13:46 -0400)
committerPatrick Palka <ppalka@redhat.com>
Wed, 21 Oct 2020 01:55:52 +0000 (21:55 -0400)
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.

(cherry picked from commit c5aad5a41838dbfd29ff114692ff9533b52746b4)

libstdc++-v3/include/std/ranges
libstdc++-v3/testsuite/std/ranges/adaptors/take_while.cc

index 98aa0d6a7c8665d7d8d1320dddf68440365255bd..23f7d9e32b1fedf7da99fe5eb9268294b5fac171 100644 (file)
@@ -2202,6 +2202,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
@@ -2211,6 +2212,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)); }
     };
index d587127b97ebe54039df6434dc73b5057d208c20..48771397f1d8be0c30025094a1a41dc1af1122dd 100644 (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();
 }
This page took 0.066635 seconds and 5 git commands to generate.