1 // { dg-do run { target c++14 } }
2 
3 // Copyright (C) 2015-2019 Free Software Foundation, Inc.
4 //
5 // This file is part of the GNU ISO C++ Library.  This library is free
6 // software; you can redistribute it and/or modify it under the
7 // terms of the GNU General Public License as published by the
8 // Free Software Foundation; either version 3, or (at your option)
9 // any later version.
10 
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 // GNU General Public License for more details.
15 
16 // You should have received a copy of the GNU General Public License along
17 // with this library; see the file COPYING3.  If not see
18 // <http://www.gnu.org/licenses/>.
19 
20 #include <experimental/map>
21 #include <testsuite_hooks.h>
22 
23 auto is_odd_pair = [](const std::pair<const int, std::string>& p)
__anona49dad170102(const std::pair<const int, std::string>& p) 24 {
25   return p.first % 2 != 0;
26 };
27 
28 void
test01()29 test01()
30 {
31   std::map<int, std::string> m{ { 10, "A" }, { 11, "B" },
32 				{ 12, "C" }, { 14, "D" },
33 				{ 15, "E" }, { 17, "F" },
34 				{ 18, "G" }, { 19, "H" } };
35   std::experimental::erase_if(m, is_odd_pair);
36   std::map<int, std::string> t{ { 10, "A" }, { 12, "C" },
37 				{ 14, "D" }, { 18, "G" } };
38   VERIFY( m == t );
39 }
40 
41 void
test02()42 test02()
43 {
44   std::multimap<int, std::string> mm{ { 20, "S" }, { 21, "T" },
45 				      { 22, "U" }, { 22, "V" },
46 				      { 23, "W" }, { 23, "X" },
47 				      { 24, "Y" }, { 25, "Z" } };
48   std::experimental::erase_if(mm, is_odd_pair);
49   std::multimap<int, std::string> t{ { 20, "S" }, { 22, "U" },
50 				     { 22, "V" }, { 24, "Y" } };
51   VERIFY( mm == t );
52 }
53 
54 int
main()55 main()
56 {
57   test01();
58   test02();
59 
60   return 0;
61 }
62