| 1 |
// { dg-options "-pedantic" } |
| 2 |
// { dg-do compile { target c++11 } } |
| 3 |
|
| 4 |
// Bug 115939 - Cannot unambiguously compare iterators in std::unordered_map |
| 5 |
|
| 6 |
#include <unordered_map> |
| 7 |
|
| 8 |
struct any_conv |
| 9 |
{ |
| 10 |
template<typename T> |
| 11 |
any_conv(T&&) { } |
| 12 |
|
| 13 |
template<typename T> |
| 14 |
friend bool operator==(const any_conv&, const T&) { return true; } |
| 15 |
|
| 16 |
template<typename T> |
| 17 |
friend bool operator!=(const any_conv&, const T&) { return false; } |
| 18 |
}; |
| 19 |
|
| 20 |
std::unordered_map<int, any_conv>::iterator i{}; |
| 21 |
std::unordered_map<int, any_conv>::const_iterator j{}; |
| 22 |
bool b1 = i == i; // { dg-bogus "ambiguous" } |
| 23 |
bool b2 = j == j; // { dg-bogus "ambiguous" } |
| 24 |
bool b3 = i == j; // { dg-bogus "ambiguous" } |
| 25 |
bool b4 = j == i; // { dg-bogus "ambiguous" } |
| 26 |
bool b5 = i != i; // { dg-bogus "ambiguous" } |
| 27 |
bool b6 = j != j; // { dg-bogus "ambiguous" } |
| 28 |
bool b7 = i != j; // { dg-bogus "ambiguous" } |
| 29 |
bool b8 = j != i; // { dg-bogus "ambiguous" } |