Skip to content

[libc++][NFC] Replace __apply_cv with __copy_cv or __copy_cvref #90867

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
May 10, 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
1 change: 0 additions & 1 deletion libcxx/include/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -731,7 +731,6 @@ set(files
__type_traits/aligned_storage.h
__type_traits/aligned_union.h
__type_traits/alignment_of.h
__type_traits/apply_cv.h
__type_traits/can_extract_key.h
__type_traits/common_reference.h
__type_traits/common_type.h
Expand Down
6 changes: 3 additions & 3 deletions libcxx/include/__tuple/make_tuple_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
#include <__tuple/tuple_indices.h>
#include <__tuple/tuple_size.h>
#include <__tuple/tuple_types.h>
#include <__type_traits/apply_cv.h>
#include <__type_traits/copy_cvref.h>
#include <__type_traits/remove_cv.h>
#include <__type_traits/remove_reference.h>
#include <cstddef>
Expand All @@ -41,15 +41,15 @@ template <template <class...> class _Tuple, class... _Types, size_t... _Idx>
struct __make_tuple_types_flat<_Tuple<_Types...>, __tuple_indices<_Idx...>> {
// Specialization for pair, tuple, and __tuple_types
template <class _Tp>
using __apply_quals _LIBCPP_NODEBUG = __tuple_types<__apply_cv_t<_Tp, __type_pack_element<_Idx, _Types...>>...>;
using __apply_quals _LIBCPP_NODEBUG = __tuple_types<__copy_cvref_t<_Tp, __type_pack_element<_Idx, _Types...>>...>;
};

template <class _Vt, size_t _Np, size_t... _Idx>
struct __make_tuple_types_flat<array<_Vt, _Np>, __tuple_indices<_Idx...>> {
template <size_t>
using __value_type = _Vt;
template <class _Tp>
using __apply_quals = __tuple_types<__apply_cv_t<_Tp, __value_type<_Idx>>...>;
using __apply_quals = __tuple_types<__copy_cvref_t<_Tp, __value_type<_Idx>>...>;
};

template <class _Tp,
Expand Down
38 changes: 0 additions & 38 deletions libcxx/include/__type_traits/apply_cv.h

This file was deleted.

3 changes: 1 addition & 2 deletions libcxx/include/__type_traits/make_signed.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
#define _LIBCPP___TYPE_TRAITS_MAKE_SIGNED_H

#include <__config>
#include <__type_traits/apply_cv.h>
#include <__type_traits/is_enum.h>
#include <__type_traits/is_integral.h>
#include <__type_traits/nat.h>
Expand Down Expand Up @@ -70,7 +69,7 @@ template <> struct __make_signed<__uint128_t, true> {typedef __int128_t t
// clang-format on

template <class _Tp>
using __make_signed_t = __apply_cv_t<_Tp, typename __make_signed<__remove_cv_t<_Tp> >::type>;
using __make_signed_t = __copy_cv_t<_Tp, typename __make_signed<__remove_cv_t<_Tp> >::type>;

#endif // __has_builtin(__make_signed)

Expand Down
4 changes: 2 additions & 2 deletions libcxx/include/__type_traits/make_unsigned.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
#define _LIBCPP___TYPE_TRAITS_MAKE_UNSIGNED_H

#include <__config>
#include <__type_traits/apply_cv.h>
#include <__type_traits/conditional.h>
#include <__type_traits/copy_cv.h>
#include <__type_traits/is_enum.h>
#include <__type_traits/is_integral.h>
#include <__type_traits/is_unsigned.h>
Expand Down Expand Up @@ -72,7 +72,7 @@ template <> struct __make_unsigned<__uint128_t, true> {typedef __uint128_
// clang-format on

template <class _Tp>
using __make_unsigned_t = __apply_cv_t<_Tp, typename __make_unsigned<__remove_cv_t<_Tp> >::type>;
using __make_unsigned_t = __copy_cv_t<_Tp, typename __make_unsigned<__remove_cv_t<_Tp> >::type>;

#endif // __has_builtin(__make_unsigned)

Expand Down
4 changes: 2 additions & 2 deletions libcxx/include/cwchar
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ size_t wcsrtombs(char* restrict dst, const wchar_t** restrict src, size_t len,
*/

#include <__config>
#include <__type_traits/apply_cv.h>
#include <__type_traits/copy_cv.h>
#include <__type_traits/is_constant_evaluated.h>
#include <__type_traits/is_equality_comparable.h>
#include <__type_traits/is_same.h>
Expand Down Expand Up @@ -236,7 +236,7 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _Tp* __constexpr_wmemchr(_Tp
wchar_t __value_buffer = 0;
__builtin_memcpy(&__value_buffer, &__value, sizeof(wchar_t));
return reinterpret_cast<_Tp*>(
__builtin_wmemchr(reinterpret_cast<__apply_cv_t<_Tp, wchar_t>*>(__str), __value_buffer, __count));
__builtin_wmemchr(reinterpret_cast<__copy_cv_t<_Tp, wchar_t>*>(__str), __value_buffer, __count));
}
# if _LIBCPP_STD_VER >= 17
else if constexpr (is_same_v<remove_cv_t<_Tp>, wchar_t>)
Expand Down
5 changes: 0 additions & 5 deletions libcxx/include/module.modulemap
Original file line number Diff line number Diff line change
Expand Up @@ -1851,11 +1851,6 @@ module std_private_type_traits_add_volatile [system
module std_private_type_traits_aligned_storage [system] { header "__type_traits/aligned_storage.h" }
module std_private_type_traits_aligned_union [system] { header "__type_traits/aligned_union.h" }
module std_private_type_traits_alignment_of [system] { header "__type_traits/alignment_of.h" }
module std_private_type_traits_apply_cv [system] {
header "__type_traits/apply_cv.h"
export std_private_type_traits_is_const
export std_private_type_traits_is_volatile
}
module std_private_type_traits_can_extract_key [system] { header "__type_traits/can_extract_key.h" }
module std_private_type_traits_common_reference [system] {
header "__type_traits/common_reference.h"
Expand Down
19 changes: 9 additions & 10 deletions libcxx/include/tuple
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,6 @@ template <class... Types>
#include <__tuple/tuple_like_ext.h>
#include <__tuple/tuple_size.h>
#include <__tuple/tuple_types.h>
#include <__type_traits/apply_cv.h>
#include <__type_traits/common_reference.h>
#include <__type_traits/common_type.h>
#include <__type_traits/conditional.h>
Expand Down Expand Up @@ -1286,14 +1285,14 @@ struct __tuple_cat_return_ref_imp;
template <class... _Types, size_t... _I0, class _Tuple0>
struct __tuple_cat_return_ref_imp<tuple<_Types...>, __tuple_indices<_I0...>, _Tuple0> {
typedef _LIBCPP_NODEBUG __libcpp_remove_reference_t<_Tuple0> _T0;
typedef tuple<_Types..., __apply_cv_t<_Tuple0, typename tuple_element<_I0, _T0>::type>&&...> type;
typedef tuple<_Types..., __copy_cvref_t<_Tuple0, typename tuple_element<_I0, _T0>::type>&&...> type;
};

template <class... _Types, size_t... _I0, class _Tuple0, class _Tuple1, class... _Tuples>
struct __tuple_cat_return_ref_imp<tuple<_Types...>, __tuple_indices<_I0...>, _Tuple0, _Tuple1, _Tuples...>
: public __tuple_cat_return_ref_imp<
tuple<_Types...,
__apply_cv_t<_Tuple0, typename tuple_element<_I0, __libcpp_remove_reference_t<_Tuple0>>::type>&&...>,
__copy_cvref_t<_Tuple0, typename tuple_element<_I0, __libcpp_remove_reference_t<_Tuple0>>::type>&&...>,
typename __make_tuple_indices<tuple_size<__libcpp_remove_reference_t<_Tuple1> >::value>::type,
_Tuple1,
_Tuples...> {};
Expand Down Expand Up @@ -1327,7 +1326,7 @@ struct __tuple_cat<tuple<_Types...>, __tuple_indices<_I0...>, __tuple_indices<_J
(void)__t; // avoid unused parameter warning on GCC when _I0 is empty
typedef _LIBCPP_NODEBUG __libcpp_remove_reference_t<_Tuple0> _T0;
typedef _LIBCPP_NODEBUG __libcpp_remove_reference_t<_Tuple1> _T1;
return __tuple_cat<tuple<_Types..., __apply_cv_t<_Tuple0, typename tuple_element<_J0, _T0>::type>&&...>,
return __tuple_cat<tuple<_Types..., __copy_cvref_t<_Tuple0, typename tuple_element<_J0, _T0>::type>&&...>,
typename __make_tuple_indices<sizeof...(_Types) + tuple_size<_T0>::value>::type,
typename __make_tuple_indices<tuple_size<_T1>::value>::type>()(
std::forward_as_tuple(
Expand Down Expand Up @@ -1375,22 +1374,22 @@ inline _LIBCPP_HIDE_FROM_ABI constexpr _Tp __make_from_tuple_impl(_Tuple&& __t,
}
#else
template <class _Tp, class _Tuple, size_t... _Idx>
inline _LIBCPP_HIDE_FROM_ABI constexpr _Tp __make_from_tuple_impl(_Tuple&& __t, __tuple_indices<_Idx...>,
inline _LIBCPP_HIDE_FROM_ABI constexpr _Tp __make_from_tuple_impl(_Tuple&& __t, __tuple_indices<_Idx...>,
enable_if_t<is_constructible_v<_Tp, decltype(std::get<_Idx>(std::forward<_Tuple>(__t)))...>> * = nullptr)
_LIBCPP_NOEXCEPT_RETURN(_Tp(std::get<_Idx>(std::forward<_Tuple>(__t))...))
#endif // _LIBCPP_STD_VER >= 20

template <class _Tp, class _Tuple,
template <class _Tp, class _Tuple,
class _Seq = typename __make_tuple_indices<tuple_size_v<remove_reference_t<_Tuple>>>::type, class = void>
inline constexpr bool __can_make_from_tuple = false;

template <class _Tp, class _Tuple, size_t... _Idx>
inline constexpr bool __can_make_from_tuple<_Tp, _Tuple, __tuple_indices<_Idx...>,
inline constexpr bool __can_make_from_tuple<_Tp, _Tuple, __tuple_indices<_Idx...>,
enable_if_t<is_constructible_v<_Tp, decltype(std::get<_Idx>(std::declval<_Tuple>()))...>>> = true;

// Based on LWG3528(https://wg21.link/LWG3528) and http://eel.is/c++draft/description#structure.requirements-9,
// the standard allows to impose requirements, we constraint std::make_from_tuple to make std::make_from_tuple
// SFINAE friendly and also avoid worse diagnostic messages. We still keep the constraints of std::__make_from_tuple_impl
// Based on LWG3528(https://wg21.link/LWG3528) and http://eel.is/c++draft/description#structure.requirements-9,
// the standard allows to impose requirements, we constraint std::make_from_tuple to make std::make_from_tuple
// SFINAE friendly and also avoid worse diagnostic messages. We still keep the constraints of std::__make_from_tuple_impl
// so that std::__make_from_tuple_impl will have the same advantages when used alone.
#if _LIBCPP_STD_VER >= 20
template <class _Tp, class _Tuple>
Expand Down
1 change: 0 additions & 1 deletion libcxx/include/type_traits
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,6 @@ namespace std
#include <__type_traits/aligned_storage.h>
#include <__type_traits/aligned_union.h>
#include <__type_traits/alignment_of.h>
#include <__type_traits/apply_cv.h>
#include <__type_traits/can_extract_key.h>
#include <__type_traits/common_reference.h>
#include <__type_traits/common_type.h>
Expand Down
Loading