-// 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>
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); });