From 0e615206e3b2c5f329cd612c09f3237c6060c06e Mon Sep 17 00:00:00 2001 From: Louis Dionne Date: Wed, 31 Jul 2024 10:40:14 -0400 Subject: [PATCH] [libc++] Revert "Use GCC type traits builtins for remove_cv and remove_cvref (#81386)" This reverts commit 55357160d0e151c32f86e1d6683b4bddbb706aa1. This is only being reverted from the LLVM 19 branch as a convenience to avoid breaking some IDEs which were not ready for that change. Fixes #99464 --- libcxx/include/__type_traits/remove_cv.h | 15 +++++++++++---- libcxx/include/__type_traits/remove_cvref.h | 15 +++++---------- 2 files changed, 16 insertions(+), 14 deletions(-) diff --git a/libcxx/include/__type_traits/remove_cv.h b/libcxx/include/__type_traits/remove_cv.h index 50e9f3e8aa78d6..c4bf612794bd55 100644 --- a/libcxx/include/__type_traits/remove_cv.h +++ b/libcxx/include/__type_traits/remove_cv.h @@ -10,6 +10,8 @@ #define _LIBCPP___TYPE_TRAITS_REMOVE_CV_H #include <__config> +#include <__type_traits/remove_const.h> +#include <__type_traits/remove_volatile.h> #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) # pragma GCC system_header @@ -17,18 +19,23 @@ _LIBCPP_BEGIN_NAMESPACE_STD +#if __has_builtin(__remove_cv) && !defined(_LIBCPP_COMPILER_GCC) template struct remove_cv { using type _LIBCPP_NODEBUG = __remove_cv(_Tp); }; -#if defined(_LIBCPP_COMPILER_GCC) template -using __remove_cv_t = typename remove_cv<_Tp>::type; +using __remove_cv_t = __remove_cv(_Tp); #else template -using __remove_cv_t = __remove_cv(_Tp); -#endif +struct _LIBCPP_TEMPLATE_VIS remove_cv { + typedef __remove_volatile_t<__remove_const_t<_Tp> > type; +}; + +template +using __remove_cv_t = __remove_volatile_t<__remove_const_t<_Tp> >; +#endif // __has_builtin(__remove_cv) #if _LIBCPP_STD_VER >= 14 template diff --git a/libcxx/include/__type_traits/remove_cvref.h b/libcxx/include/__type_traits/remove_cvref.h index 55f894dbd1d815..e8e8745ab09609 100644 --- a/libcxx/include/__type_traits/remove_cvref.h +++ b/libcxx/include/__type_traits/remove_cvref.h @@ -20,26 +20,21 @@ _LIBCPP_BEGIN_NAMESPACE_STD -#if defined(_LIBCPP_COMPILER_GCC) +#if __has_builtin(__remove_cvref) && !defined(_LIBCPP_COMPILER_GCC) template -struct __remove_cvref_gcc { - using type = __remove_cvref(_Tp); -}; - -template -using __remove_cvref_t _LIBCPP_NODEBUG = typename __remove_cvref_gcc<_Tp>::type; +using __remove_cvref_t _LIBCPP_NODEBUG = __remove_cvref(_Tp); #else template -using __remove_cvref_t _LIBCPP_NODEBUG = __remove_cvref(_Tp); +using __remove_cvref_t _LIBCPP_NODEBUG = __remove_cv_t<__libcpp_remove_reference_t<_Tp> >; #endif // __has_builtin(__remove_cvref) template -using __is_same_uncvref = _IsSame<__remove_cvref_t<_Tp>, __remove_cvref_t<_Up> >; +struct __is_same_uncvref : _IsSame<__remove_cvref_t<_Tp>, __remove_cvref_t<_Up> > {}; #if _LIBCPP_STD_VER >= 20 template struct remove_cvref { - using type _LIBCPP_NODEBUG = __remove_cvref(_Tp); + using type _LIBCPP_NODEBUG = __remove_cvref_t<_Tp>; }; template