[libcxx-commits] [libcxx] 4bc6499 - [libc++][NFC] Remove one apply_cv implementation

Nikolas Klauser via libcxx-commits libcxx-commits at lists.llvm.org
Thu Apr 20 07:07:36 PDT 2023


Author: Nikolas Klauser
Date: 2023-04-20T16:07:29+02:00
New Revision: 4bc6499f8843b71b3075aade7f5dc09dcf125ea0

URL: https://github.com/llvm/llvm-project/commit/4bc6499f8843b71b3075aade7f5dc09dcf125ea0
DIFF: https://github.com/llvm/llvm-project/commit/4bc6499f8843b71b3075aade7f5dc09dcf125ea0.diff

LOG: [libc++][NFC] Remove one apply_cv implementation

Reviewed By: #libc, ldionne

Spies: arichardson, libcxx-commits

Differential Revision: https://reviews.llvm.org/D148468

Added: 
    

Modified: 
    libcxx/include/CMakeLists.txt
    libcxx/include/__tuple/make_tuple_types.h
    libcxx/include/__type_traits/apply_cv.h
    libcxx/include/__type_traits/make_signed.h
    libcxx/include/__type_traits/make_unsigned.h
    libcxx/include/module.modulemap.in
    libcxx/include/tuple
    libcxx/test/libcxx/private_headers.verify.cpp
    libcxx/utils/data/ignore_format.txt

Removed: 
    libcxx/include/__tuple/apply_cv.h


################################################################################
diff  --git a/libcxx/include/CMakeLists.txt b/libcxx/include/CMakeLists.txt
index 439cdddbf40a4..032606d4572b6 100644
--- a/libcxx/include/CMakeLists.txt
+++ b/libcxx/include/CMakeLists.txt
@@ -596,7 +596,6 @@ set(files
   __thread/timed_backoff_policy.h
   __threading_support
   __tree
-  __tuple/apply_cv.h
   __tuple/make_tuple_types.h
   __tuple/pair_like.h
   __tuple/sfinae_helpers.h

diff  --git a/libcxx/include/__tuple/apply_cv.h b/libcxx/include/__tuple/apply_cv.h
deleted file mode 100644
index 296755a1d52dd..0000000000000
--- a/libcxx/include/__tuple/apply_cv.h
+++ /dev/null
@@ -1,70 +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___TUPLE_APPLY_CV_H
-#define _LIBCPP___TUPLE_APPLY_CV_H
-
-#include <__config>
-#include <__type_traits/is_const.h>
-#include <__type_traits/is_reference.h>
-#include <__type_traits/is_volatile.h>
-#include <__type_traits/remove_reference.h>
-
-#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#  pragma GCC system_header
-#endif
-
-#ifndef _LIBCPP_CXX03_LANG
-
-_LIBCPP_BEGIN_NAMESPACE_STD
-
-template <bool _ApplyLV, bool _ApplyConst, bool _ApplyVolatile>
-struct __apply_cv_mf;
-template <>
-struct __apply_cv_mf<false, false, false> {
-  template <class _Tp> using __apply = _Tp;
-};
-template <>
-struct __apply_cv_mf<false, true, false> {
-  template <class _Tp> using __apply _LIBCPP_NODEBUG = const _Tp;
-};
-template <>
-struct __apply_cv_mf<false, false, true> {
-  template <class _Tp> using __apply _LIBCPP_NODEBUG = volatile _Tp;
-};
-template <>
-struct __apply_cv_mf<false, true, true> {
-  template <class _Tp> using __apply _LIBCPP_NODEBUG = const volatile _Tp;
-};
-template <>
-struct __apply_cv_mf<true, false, false> {
-  template <class _Tp> using __apply _LIBCPP_NODEBUG = _Tp&;
-};
-template <>
-struct __apply_cv_mf<true, true, false> {
-  template <class _Tp> using __apply _LIBCPP_NODEBUG = const _Tp&;
-};
-template <>
-struct __apply_cv_mf<true, false, true> {
-  template <class _Tp> using __apply _LIBCPP_NODEBUG = volatile _Tp&;
-};
-template <>
-struct __apply_cv_mf<true, true, true> {
-  template <class _Tp> using __apply _LIBCPP_NODEBUG = const volatile _Tp&;
-};
-template <class _Tp, class _RawTp = __libcpp_remove_reference_t<_Tp> >
-using __apply_cv_t _LIBCPP_NODEBUG = __apply_cv_mf<
-    is_lvalue_reference<_Tp>::value,
-    is_const<_RawTp>::value,
-    is_volatile<_RawTp>::value>;
-
-_LIBCPP_END_NAMESPACE_STD
-
-#endif // _LIBCPP_CXX03_LANG
-
-#endif // _LIBCPP___TUPLE_APPLY_CV_H

diff  --git a/libcxx/include/__tuple/make_tuple_types.h b/libcxx/include/__tuple/make_tuple_types.h
index 38e2547d13dcf..aee2bde89c7f9 100644
--- a/libcxx/include/__tuple/make_tuple_types.h
+++ b/libcxx/include/__tuple/make_tuple_types.h
@@ -12,11 +12,11 @@
 #include <__config>
 #include <__fwd/array.h>
 #include <__fwd/tuple.h>
-#include <__tuple/apply_cv.h>
 #include <__tuple/tuple_element.h>
 #include <__tuple/tuple_indices.h>
 #include <__tuple/tuple_size.h>
 #include <__tuple/tuple_types.h>
+#include <__type_traits/apply_cv.h>
 #include <__type_traits/remove_cv.h>
 #include <__type_traits/remove_reference.h>
 #include <cstddef>
@@ -40,20 +40,16 @@ struct __make_tuple_types_flat;
 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, class _ApplyFn = __apply_cv_t<_Tp>>
-  using __apply_quals _LIBCPP_NODEBUG = __tuple_types<
-      typename _ApplyFn::template __apply<__type_pack_element<_Idx, _Types...>>...
-    >;
+  template <class _Tp>
+  using __apply_quals _LIBCPP_NODEBUG = __tuple_types<__apply_cv_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, class _ApplyFn = __apply_cv_t<_Tp>>
-  using __apply_quals = __tuple_types<
-      typename _ApplyFn::template __apply<__value_type<_Idx>>...
-    >;
+  template <class _Tp>
+  using __apply_quals = __tuple_types<__apply_cv_t<_Tp, __value_type<_Idx>>...>;
 };
 
 template <class _Tp, size_t _Ep = tuple_size<__libcpp_remove_reference_t<_Tp> >::value,

diff  --git a/libcxx/include/__type_traits/apply_cv.h b/libcxx/include/__type_traits/apply_cv.h
index 680ff6ac7d91a..7c6aabec8344b 100644
--- a/libcxx/include/__type_traits/apply_cv.h
+++ b/libcxx/include/__type_traits/apply_cv.h
@@ -13,7 +13,6 @@
 #include <__type_traits/is_const.h>
 #include <__type_traits/is_volatile.h>
 #include <__type_traits/remove_reference.h>
-#include <cstddef>
 
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
 #  pragma GCC system_header
@@ -21,55 +20,59 @@
 
 _LIBCPP_BEGIN_NAMESPACE_STD
 
-template <class _Tp, class _Up, bool = is_const<__libcpp_remove_reference_t<_Tp> >::value,
-                             bool = is_volatile<__libcpp_remove_reference_t<_Tp> >::value>
-struct __apply_cv
-{
-    typedef _LIBCPP_NODEBUG _Up type;
+template <class _Tp,
+          bool = is_const<__libcpp_remove_reference_t<_Tp> >::value,
+          bool = is_volatile<__libcpp_remove_reference_t<_Tp> >::value>
+struct __apply_cv_impl {
+  template <class _Up>
+  using __apply _LIBCPP_NODEBUG = _Up;
 };
 
-template <class _Tp, class _Up>
-struct __apply_cv<_Tp, _Up, true, false>
-{
-    typedef _LIBCPP_NODEBUG const _Up type;
+template <class _Tp>
+struct __apply_cv_impl<_Tp, true, false> {
+  template <class _Up>
+  using __apply _LIBCPP_NODEBUG = const _Up;
 };
 
-template <class _Tp, class _Up>
-struct __apply_cv<_Tp, _Up, false, true>
-{
-    typedef volatile _Up type;
+template <class _Tp>
+struct __apply_cv_impl<_Tp, false, true> {
+  template <class _Up>
+  using __apply _LIBCPP_NODEBUG = volatile _Up;
 };
 
-template <class _Tp, class _Up>
-struct __apply_cv<_Tp, _Up, true, true>
-{
-    typedef const volatile _Up type;
+template <class _Tp>
+struct __apply_cv_impl<_Tp, true, true> {
+  template <class _Up>
+  using __apply _LIBCPP_NODEBUG = const volatile _Up;
 };
 
-template <class _Tp, class _Up>
-struct __apply_cv<_Tp&, _Up, false, false>
-{
-    typedef _Up& type;
+template <class _Tp>
+struct __apply_cv_impl<_Tp&, false, false> {
+  template <class _Up>
+  using __apply _LIBCPP_NODEBUG = _Up&;
 };
 
-template <class _Tp, class _Up>
-struct __apply_cv<_Tp&, _Up, true, false>
-{
-    typedef const _Up& type;
+template <class _Tp>
+struct __apply_cv_impl<_Tp&, true, false> {
+  template <class _Up>
+  using __apply _LIBCPP_NODEBUG = const _Up&;
 };
 
-template <class _Tp, class _Up>
-struct __apply_cv<_Tp&, _Up, false, true>
-{
-    typedef volatile _Up& type;
+template <class _Tp>
+struct __apply_cv_impl<_Tp&, false, true> {
+  template <class _Up>
+  using __apply _LIBCPP_NODEBUG = volatile _Up&;
 };
 
-template <class _Tp, class _Up>
-struct __apply_cv<_Tp&, _Up, true, true>
-{
-    typedef const volatile _Up& type;
+template <class _Tp>
+struct __apply_cv_impl<_Tp&, true, true> {
+  template <class _Up>
+  using __apply _LIBCPP_NODEBUG = const volatile _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 71383d0e30b46..a8142a43cb515 100644
--- a/libcxx/include/__type_traits/make_signed.h
+++ b/libcxx/include/__type_traits/make_signed.h
@@ -68,7 +68,7 @@ template <> struct __make_signed<__uint128_t,        true> {typedef __int128_t t
 #  endif
 
 template <class _Tp>
-using __make_signed_t = typename __apply_cv<_Tp, typename __make_signed<__remove_cv_t<_Tp> >::type>::type;
+using __make_signed_t = __apply_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 76d1889f4d5f0..0ee4347a721aa 100644
--- a/libcxx/include/__type_traits/make_unsigned.h
+++ b/libcxx/include/__type_traits/make_unsigned.h
@@ -70,7 +70,7 @@ template <> struct __make_unsigned<__uint128_t,        true> {typedef __uint128_
 #  endif
 
 template <class _Tp>
-using __make_unsigned_t = typename __apply_cv<_Tp, typename __make_unsigned<__remove_cv_t<_Tp> >::type>::type;
+using __make_unsigned_t = __apply_cv_t<_Tp, typename __make_unsigned<__remove_cv_t<_Tp> >::type>;
 
 #endif // __has_builtin(__make_unsigned)
 

diff  --git a/libcxx/include/module.modulemap.in b/libcxx/include/module.modulemap.in
index 7a7edbfa7e939..15f089a71f704 100644
--- a/libcxx/include/module.modulemap.in
+++ b/libcxx/include/module.modulemap.in
@@ -1467,7 +1467,6 @@ module std [system] {
     header "tuple"
     export *
 
-    module apply_cv         { private header "__tuple/apply_cv.h" }
     module get_fwd          { private header "__fwd/get.h" }
     module make_tuple_types { private header "__tuple/make_tuple_types.h" }
     module pair_like        { private header "__tuple/pair_like.h" }

diff  --git a/libcxx/include/tuple b/libcxx/include/tuple
index 9ef197fa39d93..f9e9ff2e51ba6 100644
--- a/libcxx/include/tuple
+++ b/libcxx/include/tuple
@@ -1711,17 +1711,15 @@ 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..., typename __apply_cv<_Tuple0,
-                          typename tuple_element<_I0, _T0>::type>::type&&...> type;
+    typedef tuple<_Types..., __apply_cv_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..., typename __apply_cv<_Tuple0,
-               typename tuple_element<_I0,
-                  __libcpp_remove_reference_t<_Tuple0> >::type>::type&&...>,
+         tuple<_Types..., __apply_cv_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...>
 {
@@ -1761,13 +1759,9 @@ 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...,
-                  typename __apply_cv<_Tuple0, typename tuple_element<
-                                                   _J0, _T0>::type>::type&&...>,
-            typename __make_tuple_indices<sizeof...(_Types) +
-                                          tuple_size<_T0>::value>::type,
-            typename __make_tuple_indices<tuple_size<_T1>::value>::type>()(
+        return __tuple_cat<tuple<_Types..., __apply_cv_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>()(
             _VSTD::forward_as_tuple(
                 _VSTD::forward<_Types>(_VSTD::get<_I0>(__t))...,
                 _VSTD::get<_J0>(_VSTD::forward<_Tuple0>(__t0))...),

diff  --git a/libcxx/test/libcxx/private_headers.verify.cpp b/libcxx/test/libcxx/private_headers.verify.cpp
index e201605d2db01..4d5b31602b307 100644
--- a/libcxx/test/libcxx/private_headers.verify.cpp
+++ b/libcxx/test/libcxx/private_headers.verify.cpp
@@ -609,7 +609,6 @@ END-SCRIPT
 #include <__system_error/system_error.h> // expected-error@*:* {{use of private header from outside its module: '__system_error/system_error.h'}}
 #include <__thread/poll_with_backoff.h> // expected-error@*:* {{use of private header from outside its module: '__thread/poll_with_backoff.h'}}
 #include <__thread/timed_backoff_policy.h> // expected-error@*:* {{use of private header from outside its module: '__thread/timed_backoff_policy.h'}}
-#include <__tuple/apply_cv.h> // expected-error@*:* {{use of private header from outside its module: '__tuple/apply_cv.h'}}
 #include <__tuple/make_tuple_types.h> // expected-error@*:* {{use of private header from outside its module: '__tuple/make_tuple_types.h'}}
 #include <__tuple/pair_like.h> // expected-error@*:* {{use of private header from outside its module: '__tuple/pair_like.h'}}
 #include <__tuple/sfinae_helpers.h> // expected-error@*:* {{use of private header from outside its module: '__tuple/sfinae_helpers.h'}}

diff  --git a/libcxx/utils/data/ignore_format.txt b/libcxx/utils/data/ignore_format.txt
index ed596ab1e7e2c..719d0c8307080 100644
--- a/libcxx/utils/data/ignore_format.txt
+++ b/libcxx/utils/data/ignore_format.txt
@@ -616,7 +616,6 @@ libcxx/include/__thread/poll_with_backoff.h
 libcxx/include/__thread/timed_backoff_policy.h
 libcxx/include/__tree
 libcxx/include/tuple
-libcxx/include/__tuple/apply_cv.h
 libcxx/include/__tuple/make_tuple_types.h
 libcxx/include/__tuple/sfinae_helpers.h
 libcxx/include/__tuple/tuple_element.h
@@ -634,7 +633,6 @@ libcxx/include/__type_traits/add_volatile.h
 libcxx/include/__type_traits/aligned_storage.h
 libcxx/include/__type_traits/aligned_union.h
 libcxx/include/__type_traits/alignment_of.h
-libcxx/include/__type_traits/apply_cv.h
 libcxx/include/__type_traits/can_extract_key.h
 libcxx/include/__type_traits/common_reference.h
 libcxx/include/__type_traits/common_type.h


        


More information about the libcxx-commits mailing list