libstdc++: Fix use of inaccessible private member in split_view (PR93936)
[gcc.git] / libstdc++-v3 / testsuite / std / ranges / adaptors / split.cc
index e25031c0aeaaa19768d5f493cd7a12d7f8b95aa1..52b015cf0c67a46918b99a9ee1a76cecb251101c 100644 (file)
@@ -91,6 +91,23 @@ test04()
   VERIFY( i == v.end() );
 }
 
+void
+test05()
+{
+  auto as_string = [](ranges::view auto rng) {
+    auto in = rng | views::common;
+    return std::string(in.begin(), in.end());
+  };
+  std::string str
+    = "Now is the time for all good men to come to the aid of their county.";
+  auto rng
+    = str | views::split(' ') | views::transform(as_string) | views::common;
+  std::vector<std::string> words(rng.begin(), rng.end());
+  auto not_space_p = [](char c) { return c != ' '; };
+  VERIFY( ranges::equal(words | views::join,
+                       str | views::filter(not_space_p)) );
+}
+
 int
 main()
 {
@@ -98,4 +115,5 @@ main()
   test02();
   test03();
   test04();
+  test05();
 }