Skip to content

[libc++] Avoid unnecessary instantiations for __copy_cvref_t #123718

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

Merged
merged 1 commit into from
Jan 22, 2025
Merged
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
21 changes: 12 additions & 9 deletions libcxx/include/__type_traits/copy_cvref.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,23 +20,26 @@

_LIBCPP_BEGIN_NAMESPACE_STD

template <class _From, class _To>
template <class _From>
struct __copy_cvref {
using type = __copy_cv_t<_From, _To>;
template <class _To>
using __apply _LIBCPP_NODEBUG = __copy_cv_t<_From, _To>;
};

template <class _From, class _To>
struct __copy_cvref<_From&, _To> {
using type = __add_lvalue_reference_t<__copy_cv_t<_From, _To> >;
template <class _From>
struct __copy_cvref<_From&> {
template <class _To>
using __apply _LIBCPP_NODEBUG = __add_lvalue_reference_t<__copy_cv_t<_From, _To> >;
};

template <class _From, class _To>
struct __copy_cvref<_From&&, _To> {
using type = __add_rvalue_reference_t<__copy_cv_t<_From, _To> >;
template <class _From>
struct __copy_cvref<_From&&> {
template <class _To>
using __apply _LIBCPP_NODEBUG = __add_rvalue_reference_t<__copy_cv_t<_From, _To> >;
};

template <class _From, class _To>
using __copy_cvref_t _LIBCPP_NODEBUG = typename __copy_cvref<_From, _To>::type;
using __copy_cvref_t _LIBCPP_NODEBUG = typename __copy_cvref<_From>::template __apply<_To>;

_LIBCPP_END_NAMESPACE_STD

Expand Down
Loading