Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[libc++] Use GCC type traits builtins for remove_cv and remove_cvref #81386

Merged
merged 1 commit into from
Mar 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 3 additions & 8 deletions libcxx/include/__type_traits/remove_cv.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,22 +19,17 @@

_LIBCPP_BEGIN_NAMESPACE_STD

#if __has_builtin(__remove_cv) && !defined(_LIBCPP_COMPILER_GCC)
template <class _Tp>
struct remove_cv {
using type _LIBCPP_NODEBUG = __remove_cv(_Tp);
};

#if defined(_LIBCPP_COMPILER_GCC)
template <class _Tp>
using __remove_cv_t = __remove_cv(_Tp);
using __remove_cv_t = typename remove_cv<_Tp>::type;
#else
template <class _Tp>
struct _LIBCPP_TEMPLATE_VIS remove_cv {
typedef __remove_volatile_t<__remove_const_t<_Tp> > type;
};

template <class _Tp>
using __remove_cv_t = __remove_volatile_t<__remove_const_t<_Tp> >;
using __remove_cv_t = __remove_cv(_Tp);
#endif // __has_builtin(__remove_cv)

#if _LIBCPP_STD_VER >= 14
Expand Down
15 changes: 10 additions & 5 deletions libcxx/include/__type_traits/remove_cvref.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,21 +20,26 @@

_LIBCPP_BEGIN_NAMESPACE_STD

#if __has_builtin(__remove_cvref) && !defined(_LIBCPP_COMPILER_GCC)
#if defined(_LIBCPP_COMPILER_GCC)
template <class _Tp>
using __remove_cvref_t _LIBCPP_NODEBUG = __remove_cvref(_Tp);
struct __remove_cvref_gcc {
using type = __remove_cvref(_Tp);
};

template <class _Tp>
using __remove_cvref_t _LIBCPP_NODEBUG = typename __remove_cvref_gcc<_Tp>::type;
#else
template <class _Tp>
using __remove_cvref_t _LIBCPP_NODEBUG = __remove_cv_t<__libcpp_remove_reference_t<_Tp> >;
using __remove_cvref_t _LIBCPP_NODEBUG = __remove_cvref(_Tp);
#endif // __has_builtin(__remove_cvref)

template <class _Tp, class _Up>
struct __is_same_uncvref : _IsSame<__remove_cvref_t<_Tp>, __remove_cvref_t<_Up> > {};
using __is_same_uncvref = _IsSame<__remove_cvref_t<_Tp>, __remove_cvref_t<_Up> >;

#if _LIBCPP_STD_VER >= 20
template <class _Tp>
struct remove_cvref {
using type _LIBCPP_NODEBUG = __remove_cvref_t<_Tp>;
using type _LIBCPP_NODEBUG = __remove_cvref(_Tp);
};

template <class _Tp>
Expand Down
Loading