From e98be183117c3d5537d322a0d126ee92a8330543 Mon Sep 17 00:00:00 2001 From: Marshall Clow Date: Thu, 11 Oct 2018 15:38:07 +0000 Subject: [PATCH] Prefer to use the __is_XXX compiler intrinsics to the (old, busted) __has_XXX intrinsics when implementing type traits. Thanks to Richard Smith for the patch. llvm-svn: 344254 --- libcxx/include/type_traits | 55 +++++++++++++++++++++++++++----------- 1 file changed, 40 insertions(+), 15 deletions(-) diff --git a/libcxx/include/type_traits b/libcxx/include/type_traits index 7ff67bfdb73e..4a5043744514 100644 --- a/libcxx/include/type_traits +++ b/libcxx/include/type_traits @@ -3686,7 +3686,12 @@ _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_trivially_move_assignable_v // is_trivially_destructible -#if __has_feature(has_trivial_destructor) || (_GNUC_VER >= 403) +#if __has_keyword(__is_trivially_destructible) + +template struct _LIBCPP_TEMPLATE_VIS is_trivially_destructible + : public integral_constant {}; + +#elif __has_feature(has_trivial_destructor) || (_GNUC_VER >= 403) template struct _LIBCPP_TEMPLATE_VIS is_trivially_destructible : public integral_constant::value && __has_trivial_destructor(_Tp)> {}; @@ -3713,18 +3718,15 @@ _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_trivially_destructible_v // is_nothrow_constructible -#if 0 -template -struct _LIBCPP_TEMPLATE_VIS is_nothrow_constructible - : public integral_constant -{ -}; - -#else - #ifndef _LIBCPP_HAS_NO_VARIADICS -#if __has_feature(cxx_noexcept) || (_GNUC_VER >= 407 && __cplusplus >= 201103L) +#if __has_keyword(__is_nothrow_constructible) + +template +struct _LIBCPP_TEMPLATE_VIS is_nothrow_constructible + : public integral_constant {}; + +#elif __has_feature(cxx_noexcept) || (_GNUC_VER >= 407 && __cplusplus >= 201103L) template struct __libcpp_is_nothrow_constructible; @@ -3761,7 +3763,7 @@ struct _LIBCPP_TEMPLATE_VIS is_nothrow_constructible<_Tp[_Ns]> { }; -#else // __has_feature(cxx_noexcept) +#else // __has_keyword(__is_nothrow_constructible) || __has_feature(cxx_noexcept) template struct _LIBCPP_TEMPLATE_VIS is_nothrow_constructible @@ -3817,6 +3819,23 @@ struct _LIBCPP_TEMPLATE_VIS is_nothrow_constructible<_Tp, _Tp&> #else // _LIBCPP_HAS_NO_VARIADICS +#if __has_keyword(__is_nothrow_constructible) + +template +struct _LIBCPP_TEMPLATE_VIS is_nothrow_constructible + : public integral_constant {}; + +template +struct _LIBCPP_TEMPLATE_VIS is_nothrow_constructible<_Tp, _A0> + : public integral_constant {}; + +template +struct _LIBCPP_TEMPLATE_VIS is_nothrow_constructible<_Tp> + : public integral_constant {}; + +#else // __has_keyword(__is_nothrow_constructible) + template struct _LIBCPP_TEMPLATE_VIS is_nothrow_constructible @@ -3868,8 +3887,8 @@ struct _LIBCPP_TEMPLATE_VIS is_nothrow_constructible<_Tp, _Tp&, { }; +#endif // __has_keyword(__is_nothrow_constructible) #endif // _LIBCPP_HAS_NO_VARIADICS -#endif // __has_feature(is_nothrow_constructible) #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) && !defined(_LIBCPP_HAS_NO_VARIADICS) template @@ -3919,7 +3938,13 @@ _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_nothrow_move_constructible_v // is_nothrow_assignable -#if __has_feature(cxx_noexcept) || (_GNUC_VER >= 407 && __cplusplus >= 201103L) +#if __has_keyword(__is_nothrow_assignable) + +template +struct _LIBCPP_TEMPLATE_VIS is_nothrow_assignable + : public integral_constant {}; + +#elif __has_feature(cxx_noexcept) || (_GNUC_VER >= 407 && __cplusplus >= 201103L) template struct __libcpp_is_nothrow_assignable; @@ -3941,7 +3966,7 @@ struct _LIBCPP_TEMPLATE_VIS is_nothrow_assignable { }; -#else // __has_feature(cxx_noexcept) +#else // __has_keyword(__is_nothrow_assignable) || __has_feature(cxx_noexcept) template struct _LIBCPP_TEMPLATE_VIS is_nothrow_assignable