[libcxx] r236950 - Fix for LWG Issue 2059: C++0x ambiguity problem with map::erase
Marshall Clow
mclow.lists at gmail.com
Sun May 10 06:35:01 PDT 2015
Author: marshall
Date: Sun May 10 08:35:00 2015
New Revision: 236950
URL: http://llvm.org/viewvc/llvm-project?rev=236950&view=rev
Log:
Fix for LWG Issue 2059: C++0x ambiguity problem with map::erase
Modified:
libcxx/trunk/include/map
libcxx/trunk/include/set
libcxx/trunk/include/unordered_map
libcxx/trunk/include/unordered_set
libcxx/trunk/test/std/containers/associative/map/map.modifiers/erase_iter.pass.cpp
libcxx/trunk/test/std/containers/associative/multimap/multimap.modifiers/erase_iter.pass.cpp
libcxx/trunk/test/std/containers/associative/multiset/erase_iter.pass.cpp
libcxx/trunk/test/std/containers/associative/set/erase_iter.pass.cpp
libcxx/trunk/test/std/containers/unord/unord.map/unorder.map.modifiers/erase_const_iter.pass.cpp
libcxx/trunk/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/erase_const_iter.pass.cpp
libcxx/trunk/test/std/containers/unord/unord.multiset/erase_const_iter.pass.cpp
libcxx/trunk/test/std/containers/unord/unord.set/erase_const_iter.pass.cpp
Modified: libcxx/trunk/include/map
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/map?rev=236950&r1=236949&r2=236950&view=diff
==============================================================================
--- libcxx/trunk/include/map (original)
+++ libcxx/trunk/include/map Sun May 10 08:35:00 2015
@@ -136,6 +136,7 @@ public:
void insert(initializer_list<value_type> il);
iterator erase(const_iterator position);
+ iterator erase(iterator position); // C++14
size_type erase(const key_type& k);
iterator erase(const_iterator first, const_iterator last);
void clear() noexcept;
@@ -330,6 +331,7 @@ public:
void insert(initializer_list<value_type> il);
iterator erase(const_iterator position);
+ iterator erase(iterator position); // C++14
size_type erase(const key_type& k);
iterator erase(const_iterator first, const_iterator last);
void clear() noexcept;
@@ -1079,6 +1081,8 @@ public:
_LIBCPP_INLINE_VISIBILITY
iterator erase(const_iterator __p) {return __tree_.erase(__p.__i_);}
_LIBCPP_INLINE_VISIBILITY
+ iterator erase(iterator __p) {return __tree_.erase(__p.__i_);}
+ _LIBCPP_INLINE_VISIBILITY
size_type erase(const key_type& __k)
{return __tree_.__erase_unique(__k);}
_LIBCPP_INLINE_VISIBILITY
@@ -1811,6 +1815,8 @@ public:
_LIBCPP_INLINE_VISIBILITY
iterator erase(const_iterator __p) {return __tree_.erase(__p.__i_);}
_LIBCPP_INLINE_VISIBILITY
+ iterator erase(iterator __p) {return __tree_.erase(__p.__i_);}
+ _LIBCPP_INLINE_VISIBILITY
size_type erase(const key_type& __k) {return __tree_.__erase_multi(__k);}
_LIBCPP_INLINE_VISIBILITY
iterator erase(const_iterator __f, const_iterator __l)
Modified: libcxx/trunk/include/set
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/set?rev=236950&r1=236949&r2=236950&view=diff
==============================================================================
--- libcxx/trunk/include/set (original)
+++ libcxx/trunk/include/set Sun May 10 08:35:00 2015
@@ -116,6 +116,7 @@ public:
void insert(initializer_list<value_type> il);
iterator erase(const_iterator position);
+ iterator erase(iterator position); // C++14
size_type erase(const key_type& k);
iterator erase(const_iterator first, const_iterator last);
void clear() noexcept;
@@ -297,6 +298,7 @@ public:
void insert(initializer_list<value_type> il);
iterator erase(const_iterator position);
+ iterator erase(iterator position); // C++14
size_type erase(const key_type& k);
iterator erase(const_iterator first, const_iterator last);
void clear() noexcept;
Modified: libcxx/trunk/include/unordered_map
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/unordered_map?rev=236950&r1=236949&r2=236950&view=diff
==============================================================================
--- libcxx/trunk/include/unordered_map (original)
+++ libcxx/trunk/include/unordered_map Sun May 10 08:35:00 2015
@@ -123,6 +123,7 @@ public:
void insert(initializer_list<value_type>);
iterator erase(const_iterator position);
+ iterator erase(iterator position); // C++14
size_type erase(const key_type& k);
iterator erase(const_iterator first, const_iterator last);
void clear() noexcept;
@@ -287,6 +288,7 @@ public:
void insert(initializer_list<value_type>);
iterator erase(const_iterator position);
+ iterator erase(iterator position); // C++14
size_type erase(const key_type& k);
iterator erase(const_iterator first, const_iterator last);
void clear() noexcept;
@@ -944,6 +946,8 @@ public:
_LIBCPP_INLINE_VISIBILITY
iterator erase(const_iterator __p) {return __table_.erase(__p.__i_);}
_LIBCPP_INLINE_VISIBILITY
+ iterator erase(iterator __p) {return __table_.erase(__p.__i_);}
+ _LIBCPP_INLINE_VISIBILITY
size_type erase(const key_type& __k) {return __table_.__erase_unique(__k);}
_LIBCPP_INLINE_VISIBILITY
iterator erase(const_iterator __first, const_iterator __last)
@@ -1644,6 +1648,8 @@ public:
_LIBCPP_INLINE_VISIBILITY
iterator erase(const_iterator __p) {return __table_.erase(__p.__i_);}
_LIBCPP_INLINE_VISIBILITY
+ iterator erase(iterator __p) {return __table_.erase(__p.__i_);}
+ _LIBCPP_INLINE_VISIBILITY
size_type erase(const key_type& __k) {return __table_.__erase_multi(__k);}
_LIBCPP_INLINE_VISIBILITY
iterator erase(const_iterator __first, const_iterator __last)
Modified: libcxx/trunk/include/unordered_set
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/unordered_set?rev=236950&r1=236949&r2=236950&view=diff
==============================================================================
--- libcxx/trunk/include/unordered_set (original)
+++ libcxx/trunk/include/unordered_set Sun May 10 08:35:00 2015
@@ -114,6 +114,7 @@ public:
void insert(initializer_list<value_type>);
iterator erase(const_iterator position);
+ iterator erase(iterator position); // C++14
size_type erase(const key_type& k);
iterator erase(const_iterator first, const_iterator last);
void clear() noexcept;
@@ -263,6 +264,7 @@ public:
void insert(initializer_list<value_type>);
iterator erase(const_iterator position);
+ iterator erase(iterator position); // C++14
size_type erase(const key_type& k);
iterator erase(const_iterator first, const_iterator last);
void clear() noexcept;
Modified: libcxx/trunk/test/std/containers/associative/map/map.modifiers/erase_iter.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/associative/map/map.modifiers/erase_iter.pass.cpp?rev=236950&r1=236949&r2=236950&view=diff
==============================================================================
--- libcxx/trunk/test/std/containers/associative/map/map.modifiers/erase_iter.pass.cpp (original)
+++ libcxx/trunk/test/std/containers/associative/map/map.modifiers/erase_iter.pass.cpp Sun May 10 08:35:00 2015
@@ -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
}
Modified: libcxx/trunk/test/std/containers/associative/multimap/multimap.modifiers/erase_iter.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/associative/multimap/multimap.modifiers/erase_iter.pass.cpp?rev=236950&r1=236949&r2=236950&view=diff
==============================================================================
--- libcxx/trunk/test/std/containers/associative/multimap/multimap.modifiers/erase_iter.pass.cpp (original)
+++ libcxx/trunk/test/std/containers/associative/multimap/multimap.modifiers/erase_iter.pass.cpp Sun May 10 08:35:00 2015
@@ -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
}
Modified: libcxx/trunk/test/std/containers/associative/multiset/erase_iter.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/associative/multiset/erase_iter.pass.cpp?rev=236950&r1=236949&r2=236950&view=diff
==============================================================================
--- libcxx/trunk/test/std/containers/associative/multiset/erase_iter.pass.cpp (original)
+++ libcxx/trunk/test/std/containers/associative/multiset/erase_iter.pass.cpp Sun May 10 08:35:00 2015
@@ -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
}
Modified: libcxx/trunk/test/std/containers/associative/set/erase_iter.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/associative/set/erase_iter.pass.cpp?rev=236950&r1=236949&r2=236950&view=diff
==============================================================================
--- libcxx/trunk/test/std/containers/associative/set/erase_iter.pass.cpp (original)
+++ libcxx/trunk/test/std/containers/associative/set/erase_iter.pass.cpp Sun May 10 08:35:00 2015
@@ -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
}
Modified: libcxx/trunk/test/std/containers/unord/unord.map/unorder.map.modifiers/erase_const_iter.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/unord/unord.map/unorder.map.modifiers/erase_const_iter.pass.cpp?rev=236950&r1=236949&r2=236950&view=diff
==============================================================================
--- libcxx/trunk/test/std/containers/unord/unord.map/unorder.map.modifiers/erase_const_iter.pass.cpp (original)
+++ libcxx/trunk/test/std/containers/unord/unord.map/unorder.map.modifiers/erase_const_iter.pass.cpp Sun May 10 08:35:00 2015
@@ -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
}
Modified: libcxx/trunk/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/erase_const_iter.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/erase_const_iter.pass.cpp?rev=236950&r1=236949&r2=236950&view=diff
==============================================================================
--- libcxx/trunk/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/erase_const_iter.pass.cpp (original)
+++ libcxx/trunk/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/erase_const_iter.pass.cpp Sun May 10 08:35:00 2015
@@ -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
}
Modified: libcxx/trunk/test/std/containers/unord/unord.multiset/erase_const_iter.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/unord/unord.multiset/erase_const_iter.pass.cpp?rev=236950&r1=236949&r2=236950&view=diff
==============================================================================
--- libcxx/trunk/test/std/containers/unord/unord.multiset/erase_const_iter.pass.cpp (original)
+++ libcxx/trunk/test/std/containers/unord/unord.multiset/erase_const_iter.pass.cpp Sun May 10 08:35:00 2015
@@ -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
}
Modified: libcxx/trunk/test/std/containers/unord/unord.set/erase_const_iter.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/unord/unord.set/erase_const_iter.pass.cpp?rev=236950&r1=236949&r2=236950&view=diff
==============================================================================
--- libcxx/trunk/test/std/containers/unord/unord.set/erase_const_iter.pass.cpp (original)
+++ libcxx/trunk/test/std/containers/unord/unord.set/erase_const_iter.pass.cpp Sun May 10 08:35:00 2015
@@ -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
}
More information about the cfe-commits
mailing list