| 1 |
// { dg-do run { target c++11 } } |
| 2 |
|
| 3 |
// 2012-01-19 Jakub Jelinek <[email protected]> |
| 4 |
// |
| 5 |
// Copyright (C) 2012-2025 Free Software Foundation, Inc. |
| 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 |
typedef std::unordered_multimap<int, int> Mmap; |
| 29 |
typedef Mmap::iterator iterator; |
| 30 |
typedef Mmap::const_iterator const_iterator; |
| 31 |
typedef Mmap::value_type value_type; |
| 32 |
|
| 33 |
Mmap mm1; |
| 34 |
|
| 35 |
mm1.insert(value_type(11135, 1)); |
| 36 |
mm1.insert(value_type(11135, 17082)); |
| 37 |
mm1.insert(value_type(9644, 24135)); |
| 38 |
mm1.insert(value_type(9644, 9644)); |
| 39 |
mm1.insert(value_type(13984, 19841)); |
| 40 |
mm1.insert(value_type(9644, 1982)); |
| 41 |
mm1.insert(value_type(13984, 1945)); |
| 42 |
mm1.insert(value_type(7, 1982)); |
| 43 |
mm1.insert(value_type(7, 1945)); |
| 44 |
VERIFY( mm1.size() == 9 ); |
| 45 |
|
| 46 |
iterator it1 = mm1.begin(); |
| 47 |
++it1; |
| 48 |
iterator it2 = it1; |
| 49 |
++it2; |
| 50 |
++it2; |
| 51 |
iterator it3 = mm1.erase(it1, it2); |
| 52 |
VERIFY( mm1.size() == 7 ); |
| 53 |
VERIFY( it3 == it2 ); |
| 54 |
VERIFY( *it3 == *it2 ); |
| 55 |
|
| 56 |
const_iterator it4 = mm1.begin(); |
| 57 |
++it4; |
| 58 |
const_iterator it5 = it4; |
| 59 |
++it5; |
| 60 |
const_iterator it6 = mm1.erase(it4); |
| 61 |
VERIFY( mm1.size() == 6 ); |
| 62 |
VERIFY( it6 == it5 ); |
| 63 |
VERIFY( *it6 == *it5 ); |
| 64 |
} |
| 65 |
|
| 66 |
int main() |
| 67 |
{ |
| 68 |
test01(); |
| 69 |
return 0; |
| 70 |
} |