[PATCH] Avoid ambiguity between C++2a std::erase_if and LFTS version

Jonathan Wakely jwakely@redhat.com
Tue Jan 29 00:48:00 GMT 2019


These calls should have been qualified to avoid ADL anyway, but in C++2a
it becomes essential to qualify the calls in experimental::erase because
std::erase_if is also declared and the calls become ambiguous.

	* include/experimental/forward_list (experimental::erase): Qualify
	call to erase_if.
	* include/experimental/list (experimental::erase): Likewise.
	* include/std/forward_list (std::erase): Likewise.
	* include/std/list (std::erase): Likewise.

Tested x86_64-linux, committed to trunk.

-------------- next part --------------
commit b9d2ffc25b406e52ce921ced97a14fcdeabd558b
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Tue Jan 29 00:14:11 2019 +0000

    Avoid ambiguity between C++2a std::erase_if and LFTS version
    
    These calls should have been qualified to avoid ADL anyway, but in C++2a
    it becomes essential to qualify the calls in experimental::erase because
    std::erase_if is also declared and the calls become ambiguous.
    
            * include/experimental/forward_list (experimental::erase): Qualify
            call to erase_if.
            * include/experimental/list (experimental::erase): Likewise.
            * include/std/forward_list (std::erase): Likewise.
            * include/std/list (std::erase): Likewise.

diff --git a/libstdc++-v3/include/experimental/forward_list b/libstdc++-v3/include/experimental/forward_list
index 60f0564f065..f6ffbf0a0af 100644
--- a/libstdc++-v3/include/experimental/forward_list
+++ b/libstdc++-v3/include/experimental/forward_list
@@ -54,7 +54,9 @@ inline namespace fundamentals_v2
     erase(forward_list<_Tp, _Alloc>& __cont, const _Up& __value)
     {
       using __elem_type = typename forward_list<_Tp, _Alloc>::value_type;
-      erase_if(__cont, [&](__elem_type& __elem) { return __elem == __value; });
+      std::experimental::erase_if(__cont, [&](__elem_type& __elem) {
+	  return __elem == __value;
+      });
     }
 
   namespace pmr {
diff --git a/libstdc++-v3/include/experimental/list b/libstdc++-v3/include/experimental/list
index 13c33f02e72..2b7a331e63a 100644
--- a/libstdc++-v3/include/experimental/list
+++ b/libstdc++-v3/include/experimental/list
@@ -54,7 +54,9 @@ inline namespace fundamentals_v2
     erase(list<_Tp, _Alloc>& __cont, const _Up& __value)
     {
       using __elem_type = typename list<_Tp, _Alloc>::value_type;
-      erase_if(__cont, [&](__elem_type& __elem) { return __elem == __value; });
+      experimental::erase_if(__cont, [&](__elem_type& __elem) {
+	  return __elem == __value;
+      });
     }
 
 namespace pmr {
diff --git a/libstdc++-v3/include/std/forward_list b/libstdc++-v3/include/std/forward_list
index 3d3b6d4f5f6..9d6cc40593b 100644
--- a/libstdc++-v3/include/std/forward_list
+++ b/libstdc++-v3/include/std/forward_list
@@ -78,8 +78,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     erase(forward_list<_Tp, _Alloc>& __cont, const _Up& __value)
     {
       using __elem_type = typename forward_list<_Tp, _Alloc>::value_type;
-      return erase_if(__cont,
-		      [&](__elem_type& __elem) { return __elem == __value; });
+      return std::erase_if(__cont, [&](__elem_type& __elem) {
+	  return __elem == __value;
+      });
     }
 _GLIBCXX_END_NAMESPACE_VERSION
 } // namespace std
diff --git a/libstdc++-v3/include/std/list b/libstdc++-v3/include/std/list
index 7b02e8685d4..8d6ac198c9a 100644
--- a/libstdc++-v3/include/std/list
+++ b/libstdc++-v3/include/std/list
@@ -102,8 +102,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     erase(list<_Tp, _Alloc>& __cont, const _Up& __value)
     {
       using __elem_type = typename list<_Tp, _Alloc>::value_type;
-      return erase_if(__cont,
-		      [&](__elem_type& __elem) { return __elem == __value; });
+      return std::erase_if(__cont, [&](__elem_type& __elem) {
+	  return __elem == __value;
+      });
     }
 _GLIBCXX_END_NAMESPACE_VERSION
 } // namespace std


More information about the Libstdc++ mailing list