]>
Commit | Line | Data |
---|---|---|
52066eae | 1 | // { dg-do run { target c++11 } } |
ac1384b7 JJ |
2 | |
3 | // 2012-01-19 Jakub Jelinek <jakub@redhat.com> | |
4 | // | |
818ab71a | 5 | // Copyright (C) 2012-2016 Free Software Foundation, Inc. |
ac1384b7 JJ |
6 | // |
7 | // This file is part of the GNU ISO C++ Library. This library is free | |
8 | // software; you can redistribute it and/or modify it under the | |
9 | // terms of the GNU General Public License as published by the | |
10 | // Free Software Foundation; either version 3, or (at your option) | |
11 | // any later version. | |
12 | // | |
13 | // This library is distributed in the hope that it will be useful, | |
14 | // but WITHOUT ANY WARRANTY; without even the implied warranty of | |
15 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
16 | // GNU General Public License for more details. | |
17 | // | |
18 | // You should have received a copy of the GNU General Public License along | |
19 | // with this library; see the file COPYING3. If not see | |
20 | // <http://www.gnu.org/licenses/>. | |
21 | ||
22 | #include <unordered_map> | |
23 | #include <testsuite_hooks.h> | |
24 | ||
25 | // libstdc++/51845 | |
26 | void test01() | |
27 | { | |
28 | bool test __attribute__((unused)) = true; | |
29 | ||
30 | typedef std::unordered_multimap<int, int> Mmap; | |
31 | typedef Mmap::iterator iterator; | |
32 | typedef Mmap::const_iterator const_iterator; | |
33 | typedef Mmap::value_type value_type; | |
34 | ||
35 | Mmap mm1; | |
36 | ||
37 | mm1.insert(value_type(11135, 1)); | |
38 | mm1.insert(value_type(11135, 17082)); | |
39 | mm1.insert(value_type(9644, 24135)); | |
40 | mm1.insert(value_type(9644, 9644)); | |
41 | mm1.insert(value_type(13984, 19841)); | |
42 | mm1.insert(value_type(9644, 1982)); | |
43 | mm1.insert(value_type(13984, 1945)); | |
44 | mm1.insert(value_type(7, 1982)); | |
45 | mm1.insert(value_type(7, 1945)); | |
46 | VERIFY( mm1.size() == 9 ); | |
47 | ||
48 | iterator it1 = mm1.begin(); | |
49 | ++it1; | |
50 | iterator it2 = it1; | |
51 | ++it2; | |
52 | ++it2; | |
53 | iterator it3 = mm1.erase(it1, it2); | |
54 | VERIFY( mm1.size() == 7 ); | |
55 | VERIFY( it3 == it2 ); | |
56 | VERIFY( *it3 == *it2 ); | |
57 | ||
58 | const_iterator it4 = mm1.begin(); | |
59 | ++it4; | |
60 | const_iterator it5 = it4; | |
61 | ++it5; | |
62 | const_iterator it6 = mm1.erase(it4); | |
63 | VERIFY( mm1.size() == 6 ); | |
64 | VERIFY( it6 == it5 ); | |
65 | VERIFY( *it6 == *it5 ); | |
66 | } | |
67 | ||
68 | int main() | |
69 | { | |
70 | test01(); | |
71 | return 0; | |
72 | } |