]> gcc.gnu.org Git - gcc.git/blobdiff - libstdc++-v3/testsuite/23_containers/unordered_set/erasure.cc
libstdc++: Call predicate with non-const values in std::erase_if [PR107850]
[gcc.git] / libstdc++-v3 / testsuite / 23_containers / unordered_set / erasure.cc
index 4cb80413ff0f7acaaa0441d417c228beb5306d63..768454942893d38e6ff8611b7ba7470f1501d694 100644 (file)
@@ -51,11 +51,24 @@ test02()
   VERIFY( num == 4 );
 }
 
+void
+test_pr107850()
+{
+  // Predicate only callable as non-const.
+  struct Pred { bool operator()(const int&) { return false; } };
+  const Pred pred; // erase_if parameter is passed by value, so non-const.
+  std::unordered_set<int> s;
+  std::erase_if(s, pred);
+  std::unordered_multiset<int> ms;
+  std::erase_if(ms, pred);
+}
+
 int
 main()
 {
   test01();
   test02();
+  test_pr107850();
 
   return 0;
 }
This page took 0.02777 seconds and 5 git commands to generate.