aboutsummaryrefslogtreecommitdiff
path: root/libcxx/test/std
diff options
context:
space:
mode:
authorStephan T. Lavavej <stl@nuwen.net>2023-12-13 02:37:05 -0800
committerGitHub <noreply@github.com>2023-12-13 02:37:05 -0800
commit869133771af2762a7835c5691063f81675cd0ece (patch)
treec6c660a6924fc8142918dd97bf8c0ddca93b72cd /libcxx/test/std
parent9505cf457fe1b3927ff769f55f7eb2bfcce0a552 (diff)
downloadllvm-869133771af2762a7835c5691063f81675cd0ece.zip
llvm-869133771af2762a7835c5691063f81675cd0ece.tar.gz
llvm-869133771af2762a7835c5691063f81675cd0ece.tar.bz2
[libc++] `views::split` and `views::lazy_split` shouldn't be range adaptor closures (#75266)
Fixes #75002. Found while running libc++'s tests with MSVC's STL. This is a superset of #74961 that also fixes the product code and adds a regression test. Thanks again, @cpplearner! To summarize: `views::split` and `views::lazy_split` aren't unary, aren't range adaptor **closure** objects, and can't be piped. However, \[range.adaptor.object\]/8 says that `views::split(pattern)` and `views::lazy_split(pattern)` produce unary, pipeable, range adaptor closure objects. This PR adjusts the test coverage accordingly, allowing it to portably pass for libc++ and MSVC's STL.
Diffstat (limited to 'libcxx/test/std')
-rw-r--r--libcxx/test/std/ranges/range.adaptors/range.lazy.split/adaptor.pass.cpp14
-rw-r--r--libcxx/test/std/ranges/range.adaptors/range.split/adaptor.pass.cpp14
2 files changed, 20 insertions, 8 deletions
diff --git a/libcxx/test/std/ranges/range.adaptors/range.lazy.split/adaptor.pass.cpp b/libcxx/test/std/ranges/range.adaptors/range.lazy.split/adaptor.pass.cpp
index da4bd9f..6bfa0ab 100644
--- a/libcxx/test/std/ranges/range.adaptors/range.lazy.split/adaptor.pass.cpp
+++ b/libcxx/test/std/ranges/range.adaptors/range.lazy.split/adaptor.pass.cpp
@@ -40,10 +40,16 @@ static_assert(!std::is_invocable_v<decltype(std::views::lazy_split), SomeView, N
static_assert(!std::is_invocable_v<decltype(std::views::lazy_split), NotAView, SomeView>);
static_assert( std::is_invocable_v<decltype(std::views::lazy_split), SomeView, SomeView>);
-static_assert( CanBePiped<SomeView&, decltype(std::views::lazy_split)>);
-static_assert( CanBePiped<char(&)[10], decltype(std::views::lazy_split)>);
-static_assert(!CanBePiped<char(&&)[10], decltype(std::views::lazy_split)>);
-static_assert(!CanBePiped<NotAView, decltype(std::views::lazy_split)>);
+// Regression test for #75002, views::lazy_split shouldn't be a range adaptor closure
+static_assert(!CanBePiped<SomeView&, decltype(std::views::lazy_split)>);
+static_assert(!CanBePiped<char (&)[10], decltype(std::views::lazy_split)>);
+static_assert(!CanBePiped<char (&&)[10], decltype(std::views::lazy_split)>);
+static_assert(!CanBePiped<NotAView, decltype(std::views::lazy_split)>);
+
+static_assert(CanBePiped<SomeView&, decltype(std::views::lazy_split('x'))>);
+static_assert(CanBePiped<char (&)[10], decltype(std::views::lazy_split('x'))>);
+static_assert(!CanBePiped<char (&&)[10], decltype(std::views::lazy_split('x'))>);
+static_assert(!CanBePiped<NotAView, decltype(std::views::lazy_split('x'))>);
static_assert(std::same_as<decltype(std::views::lazy_split), decltype(std::ranges::views::lazy_split)>);
diff --git a/libcxx/test/std/ranges/range.adaptors/range.split/adaptor.pass.cpp b/libcxx/test/std/ranges/range.adaptors/range.split/adaptor.pass.cpp
index cd12011..85d13ac 100644
--- a/libcxx/test/std/ranges/range.adaptors/range.split/adaptor.pass.cpp
+++ b/libcxx/test/std/ranges/range.adaptors/range.split/adaptor.pass.cpp
@@ -39,10 +39,16 @@ static_assert(!std::is_invocable_v<decltype(std::views::split), SomeView, NotAVi
static_assert(!std::is_invocable_v<decltype(std::views::split), NotAView, SomeView>);
static_assert( std::is_invocable_v<decltype(std::views::split), SomeView, SomeView>);
-static_assert( CanBePiped<SomeView&, decltype(std::views::split)>);
-static_assert( CanBePiped<char(&)[10], decltype(std::views::split)>);
-static_assert(!CanBePiped<char(&&)[10], decltype(std::views::split)>);
-static_assert(!CanBePiped<NotAView, decltype(std::views::split)>);
+// Regression test for #75002, views::split shouldn't be a range adaptor closure
+static_assert(!CanBePiped<SomeView&, decltype(std::views::split)>);
+static_assert(!CanBePiped<char (&)[10], decltype(std::views::split)>);
+static_assert(!CanBePiped<char (&&)[10], decltype(std::views::split)>);
+static_assert(!CanBePiped<NotAView, decltype(std::views::split)>);
+
+static_assert(CanBePiped<SomeView&, decltype(std::views::split('x'))>);
+static_assert(CanBePiped<char (&)[10], decltype(std::views::split('x'))>);
+static_assert(!CanBePiped<char (&&)[10], decltype(std::views::split('x'))>);
+static_assert(!CanBePiped<NotAView, decltype(std::views::split('x'))>);
static_assert(std::same_as<decltype(std::views::split), decltype(std::ranges::views::split)>);