-// { dg-options "-std=gnu++2a" }
-// { dg-do run { target c++2a } }
+// { dg-do run { target c++20 } }
+// { dg-add-options no_pch }
-// Copyright (C) 2018-2019 Free Software Foundation, Inc.
+// Copyright (C) 2018-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
// <http://www.gnu.org/licenses/>.
#include <map>
-#include <testsuite_hooks.h>
#ifndef __cpp_lib_erase_if
-# error "Feature-test macro for erase_if missing"
-#elif __cpp_lib_erase_if < 201811
-# error "Feature-test macro for erase_if has wrong value"
+# error "Feature-test macro for erase_if missing in <map>"
+#elif __cpp_lib_erase_if < 202002
+# error "Feature-test macro for erase_if has wrong value in <map>"
#endif
+#include <string>
+#include <testsuite_hooks.h>
+
auto is_odd_pair = [](const std::pair<const int, std::string>& p)
{
return p.first % 2 != 0;
VERIFY( num == 4 );
}
+void
+test_pr107850()
+{
+ // Predicate only callable as non-const and only accepts non-const argument.
+ struct Pred { bool operator()(std::pair<const int, int>&) { return false; } };
+ const Pred pred; // erase_if parameter is passed by value, so non-const.
+ std::map<int, int> m;
+ std::erase_if(m, pred);
+ std::multimap<int, int> mm;
+ std::erase_if(mm, pred);
+}
+
int
main()
{
test01();
test02();
+ test_pr107850();
return 0;
}