| 1 |
// { dg-do run { target c++17 xfail *-*-* } } |
| 2 |
// { dg-require-debug-mode "" } |
| 3 |
|
| 4 |
#include <unordered_map> |
| 5 |
#include <algorithm> |
| 6 |
#include <testsuite_hooks.h> |
| 7 |
|
| 8 |
using test_type = std::unordered_map<int, int>; |
| 9 |
|
| 10 |
void |
| 11 |
test01() |
| 12 |
{ |
| 13 |
test_type c0 |
| 14 |
{ |
| 15 |
{ 1, 1 }, { 2, 2 }, { 3, 3 }, |
| 16 |
{ 5, 5 }, { 6, 6 }, { 7, 7 } |
| 17 |
}; |
| 18 |
std::unordered_multimap<int, int> c1 |
| 19 |
{ |
| 20 |
{ 1, 1 }, { 1, 1 }, { 2, 2 }, { 2, 2 }, |
| 21 |
{ 3, 3 }, { 3, 3 }, { 4, 4 }, { 4, 4 }, |
| 22 |
{ 5, 5 } |
| 23 |
}; |
| 24 |
|
| 25 |
auto it1 = c1.find(1); |
| 26 |
auto it41 = c1.find(4); |
| 27 |
auto it42 = it41; |
| 28 |
++it42; |
| 29 |
VERIFY( it42->second == 4 ); |
| 30 |
|
| 31 |
c0.merge(std::move(c1)); |
| 32 |
|
| 33 |
VERIFY( it1->second == 1 ); |
| 34 |
VERIFY( c1.count(4) == 1 ); |
| 35 |
VERIFY( it41 != it42 ); // Invalid iterator. |
| 36 |
} |
| 37 |
|
| 38 |
int |
| 39 |
main() |
| 40 |
{ |
| 41 |
test01(); |
| 42 |
} |