]> git.ipfire.org Git - thirdparty/gcc.git/blobdiff - libstdc++-v3/testsuite/std/ranges/adaptors/split.cc
Update copyright years.
[thirdparty/gcc.git] / libstdc++-v3 / testsuite / std / ranges / adaptors / split.cc
index b4e01fea6e4abc22d8418b0a33230e135da3096a..0e91482e7b7207963f87d032228e8b25d421be2d 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2020-2021 Free Software Foundation, Inc.
+// Copyright (C) 2020-2024 Free Software Foundation, Inc.
 //
 // This file is part of the GNU ISO C++ Library.  This library is free
 // software; you can redistribute it and/or modify it under the
 // with this library; see the file COPYING3.  If not see
 // <http://www.gnu.org/licenses/>.
 
-// { dg-options "-std=gnu++2a" }
-// { dg-do run { target c++2a } }
+// { dg-do run { target c++20 } }
 
 #include <algorithm>
 #include <ranges>
 #include <string>
 #include <string_view>
+#include <vector>
 #include <testsuite_hooks.h>
 #include <testsuite_iterators.h>
 
@@ -145,10 +145,15 @@ test06()
   static_assert(!requires { split(p)(); });
   static_assert(!requires { s | split; });
 
-  static_assert(!requires { s | split(p); });
-  static_assert(!requires { split(p)(s); });
-  static_assert(!requires { s | (split(p) | views::all); });
-  static_assert(!requires { (split(p) | views::all)(s); });
+  // Test the case where the closure object is used as an rvalue and therefore
+  // the copy of p is forwarded as an rvalue.
+  // This used to be invalid, but is now well-formed after P2415R2 relaxed
+  // the requirements of viewable_range to admit rvalue non-view non-borrowed
+  // ranges such as std::string&&.
+  static_assert(requires { s | split(p); });
+  static_assert(requires { split(p)(s); });
+  static_assert(requires { s | (split(p) | views::all); });
+  static_assert(requires { (split(p) | views::all)(s); });
 
   static_assert(requires { s | split(views::all(p)); });
   static_assert(requires { split(views::all(p))(s); });