[libcxx-commits] [libcxx] f755806 - Remove __uncvref; use __uncvref_t instead

Nikolas Klauser via libcxx-commits libcxx-commits at lists.llvm.org
Thu Feb 17 13:54:49 PST 2022


Author: Nikolas Klauser
Date: 2022-02-17T22:54:31+01:00
New Revision: f755806813224ca6e8c61313644ffcf48b0799b9

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

LOG: Remove __uncvref; use __uncvref_t instead

Reviewed By: Quuxplusone, #libc

Spies: libcxx-commits

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

Added: 
    libcxx/test/std/thread/futures/futures.task/futures.task.members/ctor2.compile.pass.cpp

Modified: 
    libcxx/include/__functional/bind.h
    libcxx/include/__hash_table
    libcxx/include/__memory/allocator_arg_t.h
    libcxx/include/__tree
    libcxx/include/__tuple
    libcxx/include/experimental/functional
    libcxx/include/future
    libcxx/include/thread
    libcxx/include/tuple
    libcxx/include/type_traits

Removed: 
    libcxx/test/std/thread/futures/futures.task/futures.task.members/ctor2.fail.cpp


################################################################################
diff  --git a/libcxx/include/__functional/bind.h b/libcxx/include/__functional/bind.h
index f584fc2e8d5e7..c352406f85613 100644
--- a/libcxx/include/__functional/bind.h
+++ b/libcxx/include/__functional/bind.h
@@ -25,9 +25,9 @@ _LIBCPP_BEGIN_NAMESPACE_STD
 
 template<class _Tp>
 struct is_bind_expression : _If<
-    _IsSame<_Tp, typename __uncvref<_Tp>::type>::value,
+    _IsSame<_Tp, __uncvref_t<_Tp> >::value,
     false_type,
-    is_bind_expression<typename __uncvref<_Tp>::type>
+    is_bind_expression<__uncvref_t<_Tp> >
 > {};
 
 #if _LIBCPP_STD_VER > 14
@@ -37,9 +37,9 @@ inline constexpr size_t is_bind_expression_v = is_bind_expression<_Tp>::value;
 
 template<class _Tp>
 struct is_placeholder : _If<
-    _IsSame<_Tp, typename __uncvref<_Tp>::type>::value,
+    _IsSame<_Tp, __uncvref_t<_Tp> >::value,
     integral_constant<int, 0>,
-    is_placeholder<typename __uncvref<_Tp>::type>
+    is_placeholder<__uncvref_t<_Tp> >
 > {};
 
 #if _LIBCPP_STD_VER > 14

diff  --git a/libcxx/include/__hash_table b/libcxx/include/__hash_table
index 43c15d59a1932..36f2ef7a2c7ac 100644
--- a/libcxx/include/__hash_table
+++ b/libcxx/include/__hash_table
@@ -47,7 +47,7 @@ template <class ..._Args>
 struct __is_hash_value_type : false_type {};
 
 template <class _One>
-struct __is_hash_value_type<_One> : __is_hash_value_type_imp<typename __uncvref<_One>::type> {};
+struct __is_hash_value_type<_One> : __is_hash_value_type_imp<__uncvref_t<_One> > {};
 
 _LIBCPP_FUNC_VIS
 size_t __next_prime(size_t __n);

diff  --git a/libcxx/include/__memory/allocator_arg_t.h b/libcxx/include/__memory/allocator_arg_t.h
index d93d99dea0c92..2d63b1f905e59 100644
--- a/libcxx/include/__memory/allocator_arg_t.h
+++ b/libcxx/include/__memory/allocator_arg_t.h
@@ -36,7 +36,7 @@ extern _LIBCPP_EXPORTED_FROM_ABI const allocator_arg_t allocator_arg;
 template <class _Tp, class _Alloc, class ..._Args>
 struct __uses_alloc_ctor_imp
 {
-    typedef _LIBCPP_NODEBUG typename __uncvref<_Alloc>::type _RawAlloc;
+    typedef _LIBCPP_NODEBUG __uncvref_t<_Alloc> _RawAlloc;
     static const bool __ua = uses_allocator<_Tp, _RawAlloc>::value;
     static const bool __ic =
         is_constructible<_Tp, allocator_arg_t, _Alloc, _Args...>::value;

diff  --git a/libcxx/include/__tree b/libcxx/include/__tree
index eeb6b1107e7c0..384d3835049bb 100644
--- a/libcxx/include/__tree
+++ b/libcxx/include/__tree
@@ -545,7 +545,7 @@ template <class ..._Args>
 struct __is_tree_value_type : false_type {};
 
 template <class _One>
-struct __is_tree_value_type<_One> : __is_tree_value_type_imp<typename __uncvref<_One>::type> {};
+struct __is_tree_value_type<_One> : __is_tree_value_type_imp<__uncvref_t<_One> > {};
 
 template <class _Tp>
 struct __tree_key_value_types {

diff  --git a/libcxx/include/__tuple b/libcxx/include/__tuple
index 9053c56518e0e..6d13bb24c5795 100644
--- a/libcxx/include/__tuple
+++ b/libcxx/include/__tuple
@@ -278,7 +278,7 @@ using __type_pack_element _LIBCPP_NODEBUG = typename decltype(
 #endif
 
 template <size_t _Ip, class ..._Types>
-struct _LIBCPP_TEMPLATE_VIS tuple_element<_Ip, __tuple_types<_Types...>>
+struct _LIBCPP_TEMPLATE_VIS tuple_element<_Ip, __tuple_types<_Types...> >
 {
     static_assert(_Ip < sizeof...(_Types), "tuple_element index out of range");
     typedef _LIBCPP_NODEBUG __type_pack_element<_Ip, _Types...> type;
@@ -469,8 +469,7 @@ template <class _SizeTrait, size_t _Expected>
 struct __tuple_like_with_size_imp<true, _SizeTrait, _Expected>
     : integral_constant<bool, _SizeTrait::value == _Expected> {};
 
-template <class _Tuple, size_t _ExpectedSize,
-          class _RawTuple = typename __uncvref<_Tuple>::type>
+template <class _Tuple, size_t _ExpectedSize, class _RawTuple = __uncvref_t<_Tuple> >
 using __tuple_like_with_size _LIBCPP_NODEBUG = __tuple_like_with_size_imp<
                                    __tuple_like<_RawTuple>::value,
                                    tuple_size<_RawTuple>, _ExpectedSize

diff  --git a/libcxx/include/experimental/functional b/libcxx/include/experimental/functional
index 087f7c95f5a77..1291894aa088f 100644
--- a/libcxx/include/experimental/functional
+++ b/libcxx/include/experimental/functional
@@ -208,11 +208,9 @@ public:
     pair<_RandomAccessIterator2, _RandomAccessIterator2>
     operator ()(_RandomAccessIterator2 __f, _RandomAccessIterator2 __l) const
     {
-        static_assert ( std::is_same<
-                typename std::__uncvref<typename std::iterator_traits<_RandomAccessIterator1>::value_type>::type,
-                typename std::__uncvref<typename std::iterator_traits<_RandomAccessIterator2>::value_type>::type
-                    >::value,
-                "Corpus and Pattern iterators must point to the same type" );
+        static_assert(__is_same_uncvref<typename iterator_traits<_RandomAccessIterator1>::value_type,
+                                        typename iterator_traits<_RandomAccessIterator2>::value_type>::value,
+                      "Corpus and Pattern iterators must point to the same type");
 
         if (__f      == __l )    return make_pair(__l, __l); // empty corpus
         if (__first_ == __last_) return make_pair(__f, __f); // empty pattern
@@ -360,11 +358,9 @@ public:
     pair<_RandomAccessIterator2, _RandomAccessIterator2>
     operator ()(_RandomAccessIterator2 __f, _RandomAccessIterator2 __l) const
     {
-        static_assert ( std::is_same<
-                typename std::__uncvref<typename std::iterator_traits<_RandomAccessIterator1>::value_type>::type,
-                typename std::__uncvref<typename std::iterator_traits<_RandomAccessIterator2>::value_type>::type
-                    >::value,
-                "Corpus and Pattern iterators must point to the same type" );
+        static_assert(__is_same_uncvref<typename std::iterator_traits<_RandomAccessIterator1>::value_type,
+                                        typename std::iterator_traits<_RandomAccessIterator2>::value_type>::value,
+                      "Corpus and Pattern iterators must point to the same type");
 
         if (__f      == __l )    return make_pair(__l, __l); // empty corpus
         if (__first_ == __last_) return make_pair(__f, __f); // empty pattern

diff  --git a/libcxx/include/future b/libcxx/include/future
index 00f5a68ac6b65..15685dfb22cbf 100644
--- a/libcxx/include/future
+++ b/libcxx/include/future
@@ -1885,25 +1885,11 @@ public:
     _LIBCPP_INLINE_VISIBILITY
     packaged_task() _NOEXCEPT : __p_(nullptr) {}
     template <class _Fp,
-              class = typename enable_if
-              <
-                  !is_same<
-                      typename __uncvref<_Fp>::type,
-                      packaged_task
-                      >::value
-                  >::type
-             >
+              class = __enable_if_t<!is_same<__uncvref_t<_Fp>, packaged_task>::value> >
         _LIBCPP_INLINE_VISIBILITY
         explicit packaged_task(_Fp&& __f) : __f_(_VSTD::forward<_Fp>(__f)) {}
     template <class _Fp, class _Allocator,
-              class = typename enable_if
-              <
-                  !is_same<
-                      typename __uncvref<_Fp>::type,
-                      packaged_task
-                      >::value
-                  >::type
-              >
+              class = __enable_if_t<!is_same<__uncvref_t<_Fp>, packaged_task>::value> >
         _LIBCPP_INLINE_VISIBILITY
         packaged_task(allocator_arg_t, const _Allocator& __a, _Fp&& __f)
              : __f_(allocator_arg, __a, _VSTD::forward<_Fp>(__f)),
@@ -2014,25 +2000,11 @@ public:
     _LIBCPP_INLINE_VISIBILITY
     packaged_task() _NOEXCEPT : __p_(nullptr) {}
     template <class _Fp,
-              class = typename enable_if
-              <
-                  !is_same<
-                      typename __uncvref<_Fp>::type,
-                      packaged_task
-                      >::value
-                  >::type
-              >
+              class = __enable_if_t<!is_same<__uncvref_t<_Fp>, packaged_task>::value> >
         _LIBCPP_INLINE_VISIBILITY
         explicit packaged_task(_Fp&& __f) : __f_(_VSTD::forward<_Fp>(__f)) {}
     template <class _Fp, class _Allocator,
-              class = typename enable_if
-              <
-                  !is_same<
-                      typename __uncvref<_Fp>::type,
-                      packaged_task
-                      >::value
-                  >::type
-              >
+              class = __enable_if_t<!is_same<__uncvref_t<_Fp>, packaged_task>::value> >
         _LIBCPP_INLINE_VISIBILITY
         packaged_task(allocator_arg_t, const _Allocator& __a, _Fp&& __f)
              : __f_(allocator_arg, __a, _VSTD::forward<_Fp>(__f)),

diff  --git a/libcxx/include/thread b/libcxx/include/thread
index 5aa698e1e136d..b059cfb459905 100644
--- a/libcxx/include/thread
+++ b/libcxx/include/thread
@@ -228,11 +228,7 @@ public:
     thread() _NOEXCEPT : __t_(_LIBCPP_NULL_THREAD) {}
 #ifndef _LIBCPP_CXX03_LANG
     template <class _Fp, class ..._Args,
-              class = typename enable_if
-              <
-                   !is_same<typename __uncvref<_Fp>::type, thread>::value
-              >::type
-             >
+              class = __enable_if_t<!is_same<__uncvref_t<_Fp>, thread>::value> >
         _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
         explicit thread(_Fp&& __f, _Args&&... __args);
 #else  // _LIBCPP_CXX03_LANG

diff  --git a/libcxx/include/tuple b/libcxx/include/tuple
index a28a2e81db3ec..08ded9c916eb5 100644
--- a/libcxx/include/tuple
+++ b/libcxx/include/tuple
@@ -1455,9 +1455,10 @@ struct __tuple_cat_return_1
 template <class ..._Types, class _Tuple0>
 struct __tuple_cat_return_1<tuple<_Types...>, true, _Tuple0>
 {
-    typedef _LIBCPP_NODEBUG typename __tuple_cat_type<tuple<_Types...>,
-            typename __make_tuple_types<typename __uncvref<_Tuple0>::type>::type>::type
-                                                                           type;
+  using type _LIBCPP_NODEBUG = typename __tuple_cat_type<
+      tuple<_Types...>,
+      typename __make_tuple_types<__uncvref_t<_Tuple0> >::type
+    >::type;
 };
 
 template <class ..._Types, class _Tuple0, class _Tuple1, class ..._Tuples>
@@ -1465,7 +1466,7 @@ struct __tuple_cat_return_1<tuple<_Types...>, true, _Tuple0, _Tuple1, _Tuples...
     : public __tuple_cat_return_1<
                  typename __tuple_cat_type<
                      tuple<_Types...>,
-                     typename __make_tuple_types<typename __uncvref<_Tuple0>::type>::type
+                     typename __make_tuple_types<__uncvref_t<_Tuple0> >::type
                  >::type,
                  __tuple_like<typename remove_reference<_Tuple1>::type>::value,
                  _Tuple1, _Tuples...>

diff  --git a/libcxx/include/type_traits b/libcxx/include/type_traits
index 3098b3d79f051..54df709874e15 100644
--- a/libcxx/include/type_traits
+++ b/libcxx/include/type_traits
@@ -1274,33 +1274,25 @@ template <class _Tp>
 decltype(__declval<_Tp>(0))
 declval() _NOEXCEPT;
 
-// __uncvref
-
-template <class _Tp>
-struct __uncvref  {
-    typedef _LIBCPP_NODEBUG typename remove_cv<typename remove_reference<_Tp>::type>::type type;
-};
-
 template <class _Tp>
 struct __unconstref {
     typedef _LIBCPP_NODEBUG typename remove_const<typename remove_reference<_Tp>::type>::type type;
 };
 
-#ifndef _LIBCPP_CXX03_LANG
 template <class _Tp>
-using __uncvref_t _LIBCPP_NODEBUG = typename __uncvref<_Tp>::type;
-#endif
+using __uncvref_t _LIBCPP_NODEBUG = typename remove_cv<typename remove_reference<_Tp>::type>::type;
 
 // __is_same_uncvref
 
 template <class _Tp, class _Up>
-struct __is_same_uncvref : _IsSame<typename __uncvref<_Tp>::type,
-                                   typename __uncvref<_Up>::type> {};
+struct __is_same_uncvref : _IsSame<__uncvref_t<_Tp>, __uncvref_t<_Up> > {};
 
 #if _LIBCPP_STD_VER > 17
 // remove_cvref - same as __uncvref
 template <class _Tp>
-struct remove_cvref : public __uncvref<_Tp> {};
+struct remove_cvref {
+    using type _LIBCPP_NODEBUG = __uncvref_t<_Tp>;
+};
 
 template <class _Tp> using remove_cvref_t = typename remove_cvref<_Tp>::type;
 #endif

diff  --git a/libcxx/test/std/thread/futures/futures.task/futures.task.members/ctor2.compile.pass.cpp b/libcxx/test/std/thread/futures/futures.task/futures.task.members/ctor2.compile.pass.cpp
new file mode 100644
index 0000000000000..2bc5c62758add
--- /dev/null
+++ b/libcxx/test/std/thread/futures/futures.task/futures.task.members/ctor2.compile.pass.cpp
@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: libcpp-has-no-threads
+
+// <future>
+
+// class packaged_task<R(ArgTypes...)>
+// template <class F, class Allocator>
+//   packaged_task(allocator_arg_t, const Allocator& a, F&& f);
+// These constructors shall not participate in overload resolution if
+//    decay<F>::type is the same type as std::packaged_task<R(ArgTypes...)>.
+
+#include <cassert>
+#include <future>
+
+#include "test_allocator.h"
+
+struct A {};
+using PT = std::packaged_task<A(int, char)>;
+using VPT = volatile std::packaged_task<A(int, char)>;
+
+static_assert(!std::is_constructible<PT, std::allocator_arg_t, test_allocator<A>, VPT>::value, "");
+
+using PA = std::packaged_task<A(int)>;
+using PI = std::packaged_task<int(int)>;
+
+static_assert(!std::is_constructible<PA, std::allocator_arg_t, std::allocator<A>, const PA&>::value, "");
+static_assert(!std::is_constructible<PA, std::allocator_arg_t, std::allocator<A>, const PA&&>::value, "");
+static_assert(!std::is_constructible<PA, std::allocator_arg_t, std::allocator<A>, volatile PA&>::value, "");
+static_assert(!std::is_constructible<PA, std::allocator_arg_t, std::allocator<A>, volatile PA&&>::value, "");
+
+static_assert( std::is_constructible<PA, std::allocator_arg_t, std::allocator<A>, const PI&>::value, "");
+static_assert( std::is_constructible<PA, std::allocator_arg_t, std::allocator<A>, const PI&&>::value, "");
+static_assert( std::is_constructible<PA, std::allocator_arg_t, std::allocator<A>, volatile PI&>::value, "");
+static_assert( std::is_constructible<PA, std::allocator_arg_t, std::allocator<A>, volatile PI&&>::value, "");

diff  --git a/libcxx/test/std/thread/futures/futures.task/futures.task.members/ctor2.fail.cpp b/libcxx/test/std/thread/futures/futures.task/futures.task.members/ctor2.fail.cpp
deleted file mode 100644
index 578ac661675ae..0000000000000
--- a/libcxx/test/std/thread/futures/futures.task/futures.task.members/ctor2.fail.cpp
+++ /dev/null
@@ -1,35 +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
-//
-//===----------------------------------------------------------------------===//
-//
-// UNSUPPORTED: libcpp-has-no-threads
-// UNSUPPORTED: c++03
-
-// <future>
-
-// class packaged_task<R(ArgTypes...)>
-// template <class F, class Allocator>
-//   packaged_task(allocator_arg_t, const Allocator& a, F&& f);
-// These constructors shall not participate in overload resolution if
-//    decay<F>::type is the same type as std::packaged_task<R(ArgTypes...)>.
-
-#include <future>
-#include <cassert>
-
-#include "test_allocator.h"
-
-struct A {};
-typedef std::packaged_task<A(int, char)> PT;
-typedef volatile std::packaged_task<A(int, char)> VPT;
-
-int main(int, char**)
-{
-    PT p { std::allocator_arg_t{}, test_allocator<A>{}, VPT {}}; // expected-error {{no matching constructor for initialization of 'PT' (aka 'packaged_task<A (int, char)>')}}
-    // expected-note-re at future:* 1 {{candidate template ignored: {{(disabled by 'enable_if')|(requirement '.*' was not satisfied)}}}}
-
-  return 0;
-}


        


More information about the libcxx-commits mailing list