]> git.ipfire.org Git - thirdparty/gcc.git/blob - libstdc++-v3/testsuite/23_containers/multimap/modifiers/dr130.cc
re PR c++/59378 (Internal compiler error when using __builtin_shuffle in a template...
[thirdparty/gcc.git] / libstdc++-v3 / testsuite / 23_containers / multimap / modifiers / dr130.cc
1 // { dg-options "-std=gnu++0x" }
2
3 // Copyright (C) 2009-2013 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
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
29 using namespace std;
30
31 void
32 test01()
33 {
34 bool test __attribute__((unused)) = true;
35 using namespace std;
36
37 multimap<int, int> mm0;
38 typedef multimap<int, int>::iterator iterator;
39 typedef multimap<int, int>::const_iterator const_iterator;
40 typedef multimap<int, int>::value_type value_type;
41 typedef iterator insert_return_type;
42
43 vector<insert_return_type> irt;
44 for (int i = 1; i <= 4; ++i)
45 for (int j = 1; j <= i; ++j)
46 irt.push_back( mm0.insert( value_type( i, i ) ) );
47
48 iterator pos1 = mm0.erase(irt[1]);
49 VERIFY( pos1 == irt[2] );
50
51 iterator pos2 = mm0.erase(irt[2]);
52 VERIFY( pos2 == irt[3] );
53
54 iterator pos3 = mm0.erase(irt[9]);
55 VERIFY( pos3 == mm0.end() );
56 }
57
58 void
59 test02()
60 {
61 bool test __attribute__((unused)) = true;
62 using namespace std;
63
64 multimap<int, int> mm0;
65 typedef multimap<int, int>::iterator iterator;
66 typedef multimap<int, int>::const_iterator const_iterator;
67 typedef multimap<int, int>::value_type value_type;
68 typedef iterator insert_return_type;
69
70 vector<insert_return_type> irt;
71 for (int i = 1; i <= 4; ++i)
72 for (int j = 1; j <= i; ++j)
73 irt.push_back( mm0.insert( value_type( i, i ) ) );
74
75 iterator pos1 = mm0.erase(irt[3], irt[6]);
76 VERIFY( pos1 == irt[6] );
77
78 iterator pos2 = mm0.erase(irt[6], ++irt[9]);
79 VERIFY( pos2 == mm0.end() );
80 }
81
82 int
83 main()
84 {
85 test01();
86 test02();
87 }