[PATCH] [libcxx] Correct SFINAE version of is_convertible to match spec and avoid triggering unnecessary compiler diagnostics

Albert Wong ajwong at google.com
Wed Aug 20 18:34:03 PDT 2014

gentle ping...

Comment at: include/type_traits:840
@@ -841,2 +839,3 @@
+template <class _Tp> typename remove_reference<_Tp>::type& __create();
Agustín Bergé wrote:
> Couldn't `__create` be replaced by `declval`, defined earlier in this file?
Yes...I wasn't certain why this had __source() previously.

[meta.rel]p4 calls the function create(), but you're right...it looks the same. Changed and added a comment.

Comment at: include/type_traits:842
@@ -842,1 +841,3 @@
+template <class _Tp> char helper(_Tp);
Agustín Bergé wrote:
> Shouldn't this be named `__helper` instead?

Comment at: include/type_traits:845
@@ +844,3 @@
+template <class _Tp, class _Tf>
+typename enable_if<sizeof(helper<_Tp>(__create<_Tf>())) == 1, char>::type
+    __test(int);
Agustín Bergé wrote:
> If I understand this correctly, it requires generalized SFINAE to work. Is that the intention?
I'm not sure I understand what generalized SFINAE is. I'm testing mainly by compiler.

The previous code just didn't work.


More information about the cfe-commits mailing list