On 24/01/15 22:46 +0000, Jonathan Wakely wrote:
On 24/01/15 23:03 +0100, François Dumont wrote:
types. I am also surprised that it is not using enable_if, IMHO it makes the code clearer.

It doesn't work though.

@@ -1155,9 +1150,8 @@
          return _S_iter(__y);
        }

-      template<typename _Kt,
-              typename _Req = typename __is_transparent<_Compare, _Kt>::type>
-       iterator
+      template<typename _Kt>
+       enable_if_t<__has_is_transparent<_Compare>::value, iterator>
        _M_find_tr(const _Kt& __k)

This doesn't work.

Consider:

#include <set>

struct I
{
  int i;
  operator int() const { return i; }
};

int main()
{
  std::set<int> s;
  I i = { };
  s.find(i);
}

(I will add something like this to the testsuite.)

Done with this patch, tested x86_64-linux and committed to trunk.

commit ba331e783334feb20f30f1b92a93d8c9d8f895be
Author: Jonathan Wakely <jwak...@redhat.com>
Date:   Mon Jan 26 10:43:16 2015 +0000

    	* testsuite/23_containers/set/operations/2.cc: Add test for
    	non-transparent comparison function.

diff --git a/libstdc++-v3/testsuite/23_containers/set/operations/2.cc b/libstdc++-v3/testsuite/23_containers/set/operations/2.cc
index 752bc7d..84ddd1f 100644
--- a/libstdc++-v3/testsuite/23_containers/set/operations/2.cc
+++ b/libstdc++-v3/testsuite/23_containers/set/operations/2.cc
@@ -128,6 +128,22 @@ test05()
   VERIFY( Cmp::count == 0);
 }
 
+void
+test06()
+{
+  // https://gcc.gnu.org/ml/libstdc++/2015-01/msg00176.html
+  // Verify the new function template overloads do not cause problems
+  // when the comparison function is not transparent.
+  struct I
+  {
+    int i;
+    operator int() const { return i; }
+  };
+
+  std::set<int> s;
+  I i = { };
+  s.find(i);
+}
 
 int
 main()
@@ -137,4 +153,5 @@ main()
   test03();
   test04();
   test05();
+  test06();
 }

Reply via email to