Skip to content

Commit

Permalink
Remove __uncvref; use __uncvref_t instead
Browse files Browse the repository at this point in the history
Reviewed By: Quuxplusone, #libc

Spies: libcxx-commits

Differential Revision: https://reviews.llvm.org/D119958
  • Loading branch information
philnik777 committed Feb 17, 2022
1 parent 86e26f0 commit f755806
Show file tree
Hide file tree
Showing 12 changed files with 71 additions and 109 deletions.
8 changes: 4 additions & 4 deletions libcxx/include/__functional/bind.h
Expand Up @@ -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
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion libcxx/include/__hash_table
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion libcxx/include/__memory/allocator_arg_t.h
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion libcxx/include/__tree
Expand Up @@ -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 {
Expand Down
5 changes: 2 additions & 3 deletions libcxx/include/__tuple
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down
16 changes: 6 additions & 10 deletions libcxx/include/experimental/functional
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
36 changes: 4 additions & 32 deletions libcxx/include/future
Expand Up @@ -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)),
Expand Down Expand Up @@ -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)),
Expand Down
6 changes: 1 addition & 5 deletions libcxx/include/thread
Expand Up @@ -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
Expand Down
9 changes: 5 additions & 4 deletions libcxx/include/tuple
Expand Up @@ -1455,17 +1455,18 @@ 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>
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...>
Expand Down
18 changes: 5 additions & 13 deletions libcxx/include/type_traits
Expand Up @@ -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
Expand Down
@@ -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, "");

This file was deleted.

0 comments on commit f755806

Please sign in to comment.