From c2be5ab5810ba5e7951d0bf7c1f84922356daf2c Mon Sep 17 00:00:00 2001 From: Marshall Clow Date: Mon, 10 Apr 2017 23:47:47 +0000 Subject: [PATCH] Fix PR#32605: common_type is not SFINAE-friendly llvm-svn: 299901 --- libcxx/include/type_traits | 4 +--- .../meta/meta.trans/meta.trans.other/common_type.pass.cpp | 6 +++++- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/libcxx/include/type_traits b/libcxx/include/type_traits index ec158fc081c3..c0922392a66b 100644 --- a/libcxx/include/type_traits +++ b/libcxx/include/type_traits @@ -1998,9 +1998,7 @@ struct _LIBCPP_TEMPLATE_VIS common_type {}; template struct _LIBCPP_TEMPLATE_VIS common_type<_Tp> -{ - typedef typename common_type<_Tp, _Tp>::type type; -}; + : public common_type<_Tp, _Tp> {}; // bullet 3 - sizeof...(Tp) == 2 diff --git a/libcxx/test/std/utilities/meta/meta.trans/meta.trans.other/common_type.pass.cpp b/libcxx/test/std/utilities/meta/meta.trans/meta.trans.other/common_type.pass.cpp index 736f74b4c270..db7b4c2f412a 100644 --- a/libcxx/test/std/utilities/meta/meta.trans/meta.trans.other/common_type.pass.cpp +++ b/libcxx/test/std/utilities/meta/meta.trans/meta.trans.other/common_type.pass.cpp @@ -45,6 +45,8 @@ namespace std template <> struct common_type< ::S, long> {}; template <> struct common_type > {}; + template <> struct common_type<::X > {}; + template <> struct common_type<::X, ::X > {}; } #if TEST_STD_VER >= 11 @@ -304,5 +306,7 @@ int main() static_assert((std::is_same::type, int>::value), ""); static_assert((std::is_same::type, int>::value), ""); static_assert((std::is_same::type, int>::value), ""); - + + static_assert(no_common_type >::value, ""); + static_assert(no_common_type >::value, ""); }