]> git.ipfire.org Git - thirdparty/gcc.git/blame - libstdc++-v3/testsuite/23_containers/multimap/modifiers/dr130.cc
Update copyright years.
[thirdparty/gcc.git] / libstdc++-v3 / testsuite / 23_containers / multimap / modifiers / dr130.cc
CommitLineData
52066eae 1// { dg-do run { target c++11 } }
c105751c 2
7adcbafe 3// Copyright (C) 2009-2022 Free Software Foundation, Inc.
c105751c
ESR
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
21// NOTE: This makes use of the fact that we know how moveable
22// is implemented on multiset (via swap). If the implementation changed
23// this test may begin to fail.
24
25#include <map>
26#include <vector>
27#include <testsuite_hooks.h>
28
29using namespace std;
30
31void
32test01()
33{
c105751c
ESR
34 using namespace std;
35
36 multimap<int, int> mm0;
37 typedef multimap<int, int>::iterator iterator;
38 typedef multimap<int, int>::const_iterator const_iterator;
39 typedef multimap<int, int>::value_type value_type;
40 typedef iterator insert_return_type;
41
42 vector<insert_return_type> irt;
43 for (int i = 1; i <= 4; ++i)
44 for (int j = 1; j <= i; ++j)
45 irt.push_back( mm0.insert( value_type( i, i ) ) );
46
47 iterator pos1 = mm0.erase(irt[1]);
48 VERIFY( pos1 == irt[2] );
49
50 iterator pos2 = mm0.erase(irt[2]);
51 VERIFY( pos2 == irt[3] );
52
53 iterator pos3 = mm0.erase(irt[9]);
54 VERIFY( pos3 == mm0.end() );
55}
56
57void
58test02()
59{
c105751c
ESR
60 using namespace std;
61
62 multimap<int, int> mm0;
63 typedef multimap<int, int>::iterator iterator;
64 typedef multimap<int, int>::const_iterator const_iterator;
65 typedef multimap<int, int>::value_type value_type;
66 typedef iterator insert_return_type;
67
68 vector<insert_return_type> irt;
69 for (int i = 1; i <= 4; ++i)
70 for (int j = 1; j <= i; ++j)
71 irt.push_back( mm0.insert( value_type( i, i ) ) );
72
73 iterator pos1 = mm0.erase(irt[3], irt[6]);
74 VERIFY( pos1 == irt[6] );
75
76 iterator pos2 = mm0.erase(irt[6], ++irt[9]);
77 VERIFY( pos2 == mm0.end() );
78}
79
80int
81main()
82{
83 test01();
84 test02();
85}