]>
Commit | Line | Data |
---|---|---|
52066eae | 1 | // { dg-do run { target c++11 } } |
c105751c | 2 | |
818ab71a | 3 | // Copyright (C) 2009-2016 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 <set> | |
26 | #include <vector> | |
27 | #include <testsuite_hooks.h> | |
28 | ||
29 | using namespace std; | |
30 | ||
31 | void | |
32 | test01() | |
33 | { | |
c105751c ESR |
34 | using namespace std; |
35 | ||
36 | multiset<int> ms0; | |
37 | typedef multiset<int>::iterator iterator; | |
38 | typedef multiset<int>::const_iterator const_iterator; | |
39 | typedef iterator insert_return_type; | |
40 | ||
41 | vector<insert_return_type> irt; | |
42 | for ( int i = 1; i <= 4; ++i ) | |
43 | for (int j = 1; j <= i; ++j) | |
44 | irt.push_back( ms0.insert( i ) ); | |
45 | ||
46 | iterator pos1 = ms0.erase(irt[1]); | |
47 | VERIFY( pos1 == irt[2] ); | |
48 | ||
49 | iterator pos2 = ms0.erase(irt[2]); | |
50 | VERIFY( pos2 == irt[3] ); | |
51 | ||
52 | iterator pos3 = ms0.erase(irt[9]); | |
53 | VERIFY( pos3 == ms0.end() ); | |
54 | } | |
55 | ||
56 | void | |
57 | test02() | |
58 | { | |
c105751c ESR |
59 | using namespace std; |
60 | ||
61 | multiset<int> ms0; | |
62 | typedef multiset<int>::iterator iterator; | |
63 | typedef multiset<int>::const_iterator const_iterator; | |
64 | typedef iterator insert_return_type; | |
65 | ||
66 | vector<insert_return_type> irt; | |
67 | for ( int i = 1; i <= 4; ++i ) | |
68 | for (int j = 1; j <= i; ++j) | |
69 | irt.push_back( ms0.insert( i ) ); | |
70 | ||
71 | iterator pos1 = ms0.erase(irt[3], irt[6]); | |
72 | VERIFY( pos1 == irt[6] ); | |
73 | ||
74 | iterator pos2 = ms0.erase(irt[6], ++irt[9]); | |
75 | VERIFY( pos2 == ms0.end() ); | |
76 | } | |
77 | ||
78 | int | |
79 | main() | |
80 | { | |
81 | test01(); | |
82 | test02(); | |
83 | } |