Fix for LWG Issue 2059: C++0x ambiguity problem with map::erase

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@236950 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Marshall Clow
2015-05-10 13:35:00 +00:00
parent 3607f8640d
commit 488025c316
12 changed files with 196 additions and 0 deletions

View File

@@ -18,6 +18,14 @@
#include "min_allocator.h"
struct TemplateConstructor
{
template<typename T>
TemplateConstructor (const T&) {}
};
bool operator<(const TemplateConstructor&, const TemplateConstructor&) { return false; }
int main()
{
{
@@ -234,4 +242,18 @@ int main()
assert(i == m.end());
}
#endif
#if __cplusplus >= 201402L
{
// This is LWG #2059
typedef TemplateConstructor T;
typedef std::map<T, int> C;
typedef C::iterator I;
C c;
T a{0};
I it = c.find(a);
if (it != c.end())
c.erase(it);
}
#endif
}

View File

@@ -18,6 +18,14 @@
#include "min_allocator.h"
struct TemplateConstructor
{
template<typename T>
TemplateConstructor (const T&) {}
};
bool operator<(const TemplateConstructor&, const TemplateConstructor&) { return false; }
int main()
{
{
@@ -276,4 +284,18 @@ int main()
assert(i == m.end());
}
#endif
#if __cplusplus >= 201402L
{
// This is LWG #2059
typedef TemplateConstructor T;
typedef std::multimap<T, int> C;
typedef C::iterator I;
C c;
T a{0};
I it = c.find(a);
if (it != c.end())
c.erase(it);
}
#endif
}

View File

@@ -18,6 +18,14 @@
#include "min_allocator.h"
struct TemplateConstructor
{
template<typename T>
TemplateConstructor (const T&) {}
};
bool operator<(const TemplateConstructor&, const TemplateConstructor&) { return false; }
int main()
{
{
@@ -178,4 +186,18 @@ int main()
assert(i == m.end());
}
#endif
#if __cplusplus >= 201402L
{
// This is LWG #2059
typedef TemplateConstructor T;
typedef std::multiset<T> C;
typedef C::iterator I;
C c;
T a{0};
I it = c.find(a);
if (it != c.end())
c.erase(it);
}
#endif
}

View File

@@ -18,6 +18,14 @@
#include "min_allocator.h"
struct TemplateConstructor
{
template<typename T>
TemplateConstructor (const T&) {}
};
bool operator<(const TemplateConstructor&, const TemplateConstructor&) { return false; }
int main()
{
{
@@ -178,4 +186,18 @@ int main()
assert(i == m.end());
}
#endif
#if __cplusplus >= 201402L
{
// This is LWG #2059
typedef TemplateConstructor T;
typedef std::set<T> C;
typedef C::iterator I;
C c;
T a{0};
I it = c.find(a);
if (it != c.end())
c.erase(it);
}
#endif
}

View File

@@ -21,6 +21,15 @@
#include "min_allocator.h"
struct TemplateConstructor
{
template<typename T>
TemplateConstructor (const T&) {}
};
bool operator==(const TemplateConstructor&, const TemplateConstructor&) { return false; }
struct Hash { size_t operator() (const TemplateConstructor &) const { return 0; } };
int main()
{
{
@@ -66,4 +75,18 @@ int main()
assert(c.at(4) == "four");
}
#endif
#if __cplusplus >= 201402L
{
// This is LWG #2059
typedef TemplateConstructor T;
typedef std::unordered_map<T, int, Hash> C;
typedef C::iterator I;
C m;
T a{0};
I it = m.find(a);
if (it != m.end())
m.erase(it);
}
#endif
}

View File

@@ -21,6 +21,15 @@
#include "min_allocator.h"
struct TemplateConstructor
{
template<typename T>
TemplateConstructor (const T&) {}
};
bool operator==(const TemplateConstructor&, const TemplateConstructor&) { return false; }
struct Hash { size_t operator() (const TemplateConstructor &) const { return 0; } };
int main()
{
{
@@ -114,4 +123,18 @@ int main()
assert(std::distance(c.cbegin(), c.cend()) == c.size());
}
#endif
#if __cplusplus >= 201402L
{
// This is LWG #2059
typedef TemplateConstructor T;
typedef std::unordered_multimap<T, int, Hash> C;
typedef C::iterator I;
C m;
T a{0};
I it = m.find(a);
if (it != m.end())
m.erase(it);
}
#endif
}

View File

@@ -20,6 +20,15 @@
#include "min_allocator.h"
struct TemplateConstructor
{
template<typename T>
TemplateConstructor (const T&) {}
};
bool operator==(const TemplateConstructor&, const TemplateConstructor&) { return false; }
struct Hash { size_t operator() (const TemplateConstructor &) const { return 0; } };
int main()
{
{
@@ -67,4 +76,18 @@ int main()
assert(c.count(4) == 1);
}
#endif
#if __cplusplus >= 201402L
{
// This is LWG #2059
typedef TemplateConstructor T;
typedef std::unordered_set<T, Hash> C;
typedef C::iterator I;
C m;
T a{0};
I it = m.find(a);
if (it != m.end())
m.erase(it);
}
#endif
}

View File

@@ -20,6 +20,15 @@
#include "min_allocator.h"
struct TemplateConstructor
{
template<typename T>
TemplateConstructor (const T&) {}
};
bool operator==(const TemplateConstructor&, const TemplateConstructor&) { return false; }
struct Hash { size_t operator() (const TemplateConstructor &) const { return 0; } };
int main()
{
{
@@ -64,4 +73,18 @@ int main()
assert(c.count(4) == 1);
}
#endif
#if __cplusplus >= 201402L
{
// This is LWG #2059
typedef TemplateConstructor T;
typedef std::unordered_set<T, Hash> C;
typedef C::iterator I;
C m;
T a{0};
I it = m.find(a);
if (it != m.end())
m.erase(it);
}
#endif
}