[libcxx-commits] [libcxx] 05f88b1 - [libc++][NFC] Replace __apply_cv with __copy_cv or __copy_cvref (#90867)
via libcxx-commits
libcxx-commits at lists.llvm.org
Fri May 10 11:06:25 PDT 2024
Author: Nikolas Klauser
Date: 2024-05-10T20:06:21+02:00
New Revision: 05f88b1769db90c10ca66810720b2092f9d73e34
URL: https://github.com/llvm/llvm-project/commit/05f88b1769db90c10ca66810720b2092f9d73e34
DIFF: https://github.com/llvm/llvm-project/commit/05f88b1769db90c10ca66810720b2092f9d73e34.diff
LOG: [libc++][NFC] Replace __apply_cv with __copy_cv or __copy_cvref (#90867)
`__apply_cv_t` and `__copy_cvref_t` are very closely related. They are
in fact identical except that `__copy_cvref_t` handles rvalue references
properly. Some uses don't actually require handling of references, so
they are replaced with `__copy_cv_t`.
Added:
Modified:
libcxx/include/CMakeLists.txt
libcxx/include/__tuple/make_tuple_types.h
libcxx/include/__type_traits/make_signed.h
libcxx/include/__type_traits/make_unsigned.h
libcxx/include/cwchar
libcxx/include/module.modulemap
libcxx/include/tuple
libcxx/include/type_traits
Removed:
libcxx/include/__type_traits/apply_cv.h
################################################################################
diff --git a/libcxx/include/CMakeLists.txt b/libcxx/include/CMakeLists.txt
index fd7eb125e007b..96d7b4037e106 100644
--- a/libcxx/include/CMakeLists.txt
+++ b/libcxx/include/CMakeLists.txt
@@ -733,7 +733,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
diff --git a/libcxx/include/__tuple/make_tuple_types.h b/libcxx/include/__tuple/make_tuple_types.h
index 43161b17cfa3a..9e0fefae2f2f5 100644
--- a/libcxx/include/__tuple/make_tuple_types.h
+++ b/libcxx/include/__tuple/make_tuple_types.h
@@ -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>
@@ -41,7 +41,7 @@ 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>
@@ -49,7 +49,7 @@ 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,
diff --git a/libcxx/include/__type_traits/apply_cv.h b/libcxx/include/__type_traits/apply_cv.h
deleted file mode 100644
index 723af95b8d928..0000000000000
--- a/libcxx/include/__type_traits/apply_cv.h
+++ /dev/null
@@ -1,38 +0,0 @@
-//===----------------------------------------------------------------------===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef _LIBCPP___TYPE_TRAITS_APPLY_CV_H
-#define _LIBCPP___TYPE_TRAITS_APPLY_CV_H
-
-#include <__config>
-#include <__type_traits/copy_cv.h>
-
-#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-# pragma GCC system_header
-#endif
-
-_LIBCPP_BEGIN_NAMESPACE_STD
-
-template <class _Tp>
-struct __apply_cv_impl {
- template <class _Up>
- using __apply _LIBCPP_NODEBUG = __copy_cv_t<_Tp, _Up>;
-};
-
-template <class _Tp>
-struct __apply_cv_impl<_Tp&> {
- template <class _Up>
- using __apply _LIBCPP_NODEBUG = __copy_cv_t<_Tp, _Up>&;
-};
-
-template <class _Tp, class _Up>
-using __apply_cv_t _LIBCPP_NODEBUG = typename __apply_cv_impl<_Tp>::template __apply<_Up>;
-
-_LIBCPP_END_NAMESPACE_STD
-
-#endif // _LIBCPP___TYPE_TRAITS_APPLY_CV_H
diff --git a/libcxx/include/__type_traits/make_signed.h b/libcxx/include/__type_traits/make_signed.h
index 1a8a35f3859d2..c1fc009d9ba2e 100644
--- a/libcxx/include/__type_traits/make_signed.h
+++ b/libcxx/include/__type_traits/make_signed.h
@@ -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>
@@ -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)
diff --git a/libcxx/include/__type_traits/make_unsigned.h b/libcxx/include/__type_traits/make_unsigned.h
index 98967371e7738..282cd2d911316 100644
--- a/libcxx/include/__type_traits/make_unsigned.h
+++ b/libcxx/include/__type_traits/make_unsigned.h
@@ -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>
@@ -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)
diff --git a/libcxx/include/cwchar b/libcxx/include/cwchar
index 4cc6f56c389bf..08cfac58c846a 100644
--- a/libcxx/include/cwchar
+++ b/libcxx/include/cwchar
@@ -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>
@@ -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>)
diff --git a/libcxx/include/module.modulemap b/libcxx/include/module.modulemap
index 2974d12500c4c..0ee0cdce61bc0 100644
--- a/libcxx/include/module.modulemap
+++ b/libcxx/include/module.modulemap
@@ -1860,11 +1860,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"
diff --git a/libcxx/include/tuple b/libcxx/include/tuple
index ace5f2328a457..e7b43af7d13c0 100644
--- a/libcxx/include/tuple
+++ b/libcxx/include/tuple
@@ -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>
@@ -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...> {};
@@ -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(
diff --git a/libcxx/include/type_traits b/libcxx/include/type_traits
index 10f9b881c0e4a..aee9fcf4137f3 100644
--- a/libcxx/include/type_traits
+++ b/libcxx/include/type_traits
@@ -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>
More information about the libcxx-commits
mailing list