-// { dg-options "-std=gnu++14" }
-// { dg-do run }
+// { dg-do run { target c++14 } }
-// Copyright (C) 2015-2016 Free Software Foundation, Inc.
+// Copyright (C) 2015-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
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
-// You should have received a moved_to of the GNU General Public License along
+// You should have received a copy of the GNU General Public License along
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
#include <experimental/unordered_map>
+#include <string>
#include <testsuite_hooks.h>
auto is_odd_pair = [](const std::pair<const int, std::string>& p)
void
test01()
{
- bool test [[gnu::unused]] = true;
-
std::unordered_map<int, std::string> um{ { 10, "A" }, { 11, "B" },
{ 12, "C" }, { 14, "D" },
{ 15, "E" }, { 17, "F" },
void
test02()
{
- bool test [[gnu::unused]] = true;
-
std::unordered_multimap<int, std::string> umm{ { 20, "S" }, { 21, "T" },
{ 22, "U" }, { 22, "V" },
{ 23, "W" }, { 23, "X" },
VERIFY( umm == t );
}
+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::unordered_map<int, int> m;
+ std::experimental::erase_if(m, pred);
+ std::unordered_multimap<int, int> mm;
+ std::experimental::erase_if(mm, pred);
+}
+
int
main()
{
test01();
test02();
+ test_pr107850();
return 0;
}