From f755806813224ca6e8c61313644ffcf48b0799b9 Mon Sep 17 00:00:00 2001 From: Nikolas Klauser Date: Thu, 17 Feb 2022 22:53:20 +0100 Subject: [PATCH] Remove __uncvref; use __uncvref_t instead Reviewed By: Quuxplusone, #libc Spies: libcxx-commits Differential Revision: https://reviews.llvm.org/D119958 --- libcxx/include/__functional/bind.h | 8 ++--- libcxx/include/__hash_table | 2 +- libcxx/include/__memory/allocator_arg_t.h | 2 +- libcxx/include/__tree | 2 +- libcxx/include/__tuple | 5 ++- libcxx/include/experimental/functional | 16 ++++----- libcxx/include/future | 36 +++---------------- libcxx/include/thread | 6 +--- libcxx/include/tuple | 9 ++--- libcxx/include/type_traits | 18 +++------- .../futures.task.members/ctor2.compile.pass.cpp | 41 ++++++++++++++++++++++ .../futures.task.members/ctor2.fail.cpp | 35 ------------------ 12 files changed, 71 insertions(+), 109 deletions(-) create mode 100644 libcxx/test/std/thread/futures/futures.task/futures.task.members/ctor2.compile.pass.cpp delete mode 100644 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 f584fc2..c352406 100644 --- a/libcxx/include/__functional/bind.h +++ b/libcxx/include/__functional/bind.h @@ -25,9 +25,9 @@ _LIBCPP_BEGIN_NAMESPACE_STD template struct is_bind_expression : _If< - _IsSame<_Tp, typename __uncvref<_Tp>::type>::value, + _IsSame<_Tp, __uncvref_t<_Tp> >::value, false_type, - is_bind_expression::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 struct is_placeholder : _If< - _IsSame<_Tp, typename __uncvref<_Tp>::type>::value, + _IsSame<_Tp, __uncvref_t<_Tp> >::value, integral_constant, - is_placeholder::type> + is_placeholder<__uncvref_t<_Tp> > > {}; #if _LIBCPP_STD_VER > 14 diff --git a/libcxx/include/__hash_table b/libcxx/include/__hash_table index 43c15d5..36f2ef7 100644 --- a/libcxx/include/__hash_table +++ b/libcxx/include/__hash_table @@ -47,7 +47,7 @@ template struct __is_hash_value_type : false_type {}; template -struct __is_hash_value_type<_One> : __is_hash_value_type_imp::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 d93d99d..2d63b1f 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 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 eeb6b11..384d383 100644 --- a/libcxx/include/__tree +++ b/libcxx/include/__tree @@ -545,7 +545,7 @@ template struct __is_tree_value_type : false_type {}; template -struct __is_tree_value_type<_One> : __is_tree_value_type_imp::type> {}; +struct __is_tree_value_type<_One> : __is_tree_value_type_imp<__uncvref_t<_One> > {}; template struct __tree_key_value_types { diff --git a/libcxx/include/__tuple b/libcxx/include/__tuple index 9053c56..6d13bb2 100644 --- a/libcxx/include/__tuple +++ b/libcxx/include/__tuple @@ -278,7 +278,7 @@ using __type_pack_element _LIBCPP_NODEBUG = typename decltype( #endif template -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 struct __tuple_like_with_size_imp : integral_constant {}; -template ::type> +template > 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 087f7c9..1291894 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::value_type>::type, - typename std::__uncvref::value_type>::type - >::value, - "Corpus and Pattern iterators must point to the same type" ); + static_assert(__is_same_uncvref::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::value_type>::type, - typename std::__uncvref::value_type>::type - >::value, - "Corpus and Pattern iterators must point to the same type" ); + static_assert(__is_same_uncvref::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 00f5a68..15685df 100644 --- a/libcxx/include/future +++ b/libcxx/include/future @@ -1885,25 +1885,11 @@ public: _LIBCPP_INLINE_VISIBILITY packaged_task() _NOEXCEPT : __p_(nullptr) {} template ::type, - packaged_task - >::value - >::type - > + class = __enable_if_t, packaged_task>::value> > _LIBCPP_INLINE_VISIBILITY explicit packaged_task(_Fp&& __f) : __f_(_VSTD::forward<_Fp>(__f)) {} template ::type, - packaged_task - >::value - >::type - > + class = __enable_if_t, 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 ::type, - packaged_task - >::value - >::type - > + class = __enable_if_t, packaged_task>::value> > _LIBCPP_INLINE_VISIBILITY explicit packaged_task(_Fp&& __f) : __f_(_VSTD::forward<_Fp>(__f)) {} template ::type, - packaged_task - >::value - >::type - > + class = __enable_if_t, 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 5aa698e..b059cfb 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 ::type, thread>::value - >::type - > + class = __enable_if_t, 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 a28a2e8..08ded9c 100644 --- a/libcxx/include/tuple +++ b/libcxx/include/tuple @@ -1455,9 +1455,10 @@ struct __tuple_cat_return_1 template struct __tuple_cat_return_1, true, _Tuple0> { - typedef _LIBCPP_NODEBUG typename __tuple_cat_type, - typename __make_tuple_types::type>::type>::type - type; + using type _LIBCPP_NODEBUG = typename __tuple_cat_type< + tuple<_Types...>, + typename __make_tuple_types<__uncvref_t<_Tuple0> >::type + >::type; }; template @@ -1465,7 +1466,7 @@ struct __tuple_cat_return_1, true, _Tuple0, _Tuple1, _Tuples... : public __tuple_cat_return_1< typename __tuple_cat_type< tuple<_Types...>, - typename __make_tuple_types::type>::type + typename __make_tuple_types<__uncvref_t<_Tuple0> >::type >::type, __tuple_like::type>::value, _Tuple1, _Tuples...> diff --git a/libcxx/include/type_traits b/libcxx/include/type_traits index 3098b3d..54df709 100644 --- a/libcxx/include/type_traits +++ b/libcxx/include/type_traits @@ -1274,33 +1274,25 @@ template decltype(__declval<_Tp>(0)) declval() _NOEXCEPT; -// __uncvref - -template -struct __uncvref { - typedef _LIBCPP_NODEBUG typename remove_cv::type>::type type; -}; - template struct __unconstref { typedef _LIBCPP_NODEBUG typename remove_const::type>::type type; }; -#ifndef _LIBCPP_CXX03_LANG template -using __uncvref_t _LIBCPP_NODEBUG = typename __uncvref<_Tp>::type; -#endif +using __uncvref_t _LIBCPP_NODEBUG = typename remove_cv::type>::type; // __is_same_uncvref template -struct __is_same_uncvref : _IsSame::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 -struct remove_cvref : public __uncvref<_Tp> {}; +struct remove_cvref { + using type _LIBCPP_NODEBUG = __uncvref_t<_Tp>; +}; template 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 0000000..2bc5c62 --- /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 + +// + +// class packaged_task +// template +// packaged_task(allocator_arg_t, const Allocator& a, F&& f); +// These constructors shall not participate in overload resolution if +// decay::type is the same type as std::packaged_task. + +#include +#include + +#include "test_allocator.h" + +struct A {}; +using PT = std::packaged_task; +using VPT = volatile std::packaged_task; + +static_assert(!std::is_constructible, VPT>::value, ""); + +using PA = std::packaged_task; +using PI = std::packaged_task; + +static_assert(!std::is_constructible, const PA&>::value, ""); +static_assert(!std::is_constructible, const PA&&>::value, ""); +static_assert(!std::is_constructible, volatile PA&>::value, ""); +static_assert(!std::is_constructible, volatile PA&&>::value, ""); + +static_assert( std::is_constructible, const PI&>::value, ""); +static_assert( std::is_constructible, const PI&&>::value, ""); +static_assert( std::is_constructible, volatile PI&>::value, ""); +static_assert( std::is_constructible, 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 578ac66..0000000 --- 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 - -// - -// class packaged_task -// template -// packaged_task(allocator_arg_t, const Allocator& a, F&& f); -// These constructors shall not participate in overload resolution if -// decay::type is the same type as std::packaged_task. - -#include -#include - -#include "test_allocator.h" - -struct A {}; -typedef std::packaged_task PT; -typedef volatile std::packaged_task VPT; - -int main(int, char**) -{ - PT p { std::allocator_arg_t{}, test_allocator{}, VPT {}}; // expected-error {{no matching constructor for initialization of 'PT' (aka 'packaged_task')}} - // expected-note-re@future:* 1 {{candidate template ignored: {{(disabled by 'enable_if')|(requirement '.*' was not satisfied)}}}} - - return 0; -} -- 2.7.4