Skip to content

Commit

Permalink
remove duplicated __apply_cv type trait; rename to __copy_cvref (#…
Browse files Browse the repository at this point in the history
…2754)

replace `__copy_cv`, `__copy_cvref`, and `cudax::__async::__copy_cvref` also, and rename `__apply_cv` to `__copy_cvref`.

---------

Co-authored-by: Michael Schellenberger Costa <[email protected]>
  • Loading branch information
ericniebler and miscco authored Nov 11, 2024
1 parent 2dbf83e commit 932ab54
Show file tree
Hide file tree
Showing 17 changed files with 598 additions and 275 deletions.
17 changes: 17 additions & 0 deletions cudax/include/cuda/experimental/__async/meta.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -474,6 +474,23 @@ struct __mquote<_Fn, _Default>
using __f = typename __mif<__mvalid_q<_Fn, _Ts...>, __mquote<_Fn>, __malways<_Default>>::template __f<_Ts...>;
};

template <template <class> class _Fn, class... _Default>
struct __mquote1;

template <template <class> class _Fn>
struct __mquote1<_Fn>
{
template <class _Ty>
using __f = _Fn<_Ty>;
};

template <template <class> class _Fn, class _Default>
struct __mquote1<_Fn, _Default>
{
template <class _Ty>
using __f = typename __mif<__mvalid_q<_Fn, _Ty>, __mquote1<_Fn>, __malways<_Default>>::template __f<_Ty>;
};

template <template <class...> class _Fn, class... _Default>
struct __mtry_quote;

Expand Down
58 changes: 8 additions & 50 deletions cudax/include/cuda/experimental/__async/type_traits.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
# pragma system_header
#endif // no system header

#include <cuda/std/__type_traits/copy_cvref.h>
#include <cuda/std/__type_traits/remove_reference.h>

#include <cuda/experimental/__async/meta.cuh>
Expand Down Expand Up @@ -132,59 +133,16 @@ using __decay_t = typename decltype(__mdecay<_Ty>)::template __f<_Ty>;

//////////////////////////////////////////////////////////////////////////////////////////////////
// __copy_cvref_t: For copying cvref from one type to another
struct __cp
{
template <class _Tp>
using __f = _Tp;
};

struct __cpc
{
template <class _Tp>
using __f = const _Tp;
};

struct __cplr
{
template <class _Tp>
using __f = _Tp&;
};

struct __cprr
{
template <class _Tp>
using __f = _Tp&&;
};

struct __cpclr
{
template <class _Tp>
using __f = const _Tp&;
};

struct __cpcrr
{
template <class _Tp>
using __f = const _Tp&&;
};
// TODO: This is a temporary implementation. We should merge this file and meta.cuh
// with the facilities in <cuda/std/__type_traits/type_list.h>.
template <class _Ty>
using __cref_t = _Ty const&;

template <class>
extern __cp __cpcvr;
template <class _Tp>
extern __cpc __cpcvr<const _Tp>;
template <class _Tp>
extern __cplr __cpcvr<_Tp&>;
template <class _Tp>
extern __cprr __cpcvr<_Tp&&>;
template <class _Tp>
extern __cpclr __cpcvr<const _Tp&>;
template <class _Tp>
extern __cpcrr __cpcvr<const _Tp&&>;
template <class _Tp>
using __copy_cvref_fn = decltype(__cpcvr<_Tp>);
using __cp = __midentity;
using __cpclr = __mquote1<__cref_t>;

template <class _From, class _To>
using __copy_cvref_t = typename __copy_cvref_fn<_From>::template __f<_To>;
using __copy_cvref_t = _CUDA_VSTD::__copy_cvref_t<_From, _To>;

template <class _Fn, class... _As>
using __call_result_t = decltype(__declval<_Fn>()(__declval<_As>()...));
Expand Down
3 changes: 1 addition & 2 deletions cudax/include/cuda/experimental/__async/when_all.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -622,8 +622,7 @@ struct __when_all::__sndr_t
}

template <class _Rcvr>
_CUDAX_API auto connect(_Rcvr __rcvr) const& //
-> __opstate_t<_Rcvr, __cpclr, __sndrs_t>
_CUDAX_API auto connect(_Rcvr __rcvr) const& -> __opstate_t<_Rcvr, __cpclr, __sndrs_t>
{
return __opstate_t<_Rcvr, __cpclr, __sndrs_t>(__sndrs_, static_cast<_Rcvr&&>(__rcvr));
}
Expand Down
2 changes: 1 addition & 1 deletion libcudacxx/include/cuda/std/__functional/invoke.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
#endif // no system header

#include <cuda/std/__type_traits/add_lvalue_reference.h>
#include <cuda/std/__type_traits/apply_cv.h>
#include <cuda/std/__type_traits/conditional.h>
#include <cuda/std/__type_traits/copy_cvref.h>
#include <cuda/std/__type_traits/decay.h>
#include <cuda/std/__type_traits/enable_if.h>
#include <cuda/std/__type_traits/integral_constant.h>
Expand Down
86 changes: 0 additions & 86 deletions libcudacxx/include/cuda/std/__tuple_dir/apply_cv.h

This file was deleted.

10 changes: 5 additions & 5 deletions libcudacxx/include/cuda/std/__tuple_dir/make_tuple_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@

#include <cuda/std/__fwd/array.h>
#include <cuda/std/__fwd/tuple.h>
#include <cuda/std/__tuple_dir/apply_cv.h>
#include <cuda/std/__tuple_dir/tuple_element.h>
#include <cuda/std/__tuple_dir/tuple_indices.h>
#include <cuda/std/__tuple_dir/tuple_size.h>
#include <cuda/std/__tuple_dir/tuple_types.h>
#include <cuda/std/__type_traits/copy_cvref.h>
#include <cuda/std/__type_traits/remove_cv.h>
#include <cuda/std/__type_traits/remove_reference.h>
#include <cuda/std/__type_traits/type_list.h>
Expand All @@ -48,18 +48,18 @@ struct __make_tuple_types_flat<_Tuple<_Types...>, __tuple_indices<_Idx...>>
using __tuple_types_list = __type_list<_Types...>;

// Specialization for pair, tuple, and __tuple_types
template <class _Tp, class _ApplyFn = __apply_cv_t<_Tp>>
template <class _Tp, class _ApplyFn = __apply_cvref_fn<_Tp>>
using __apply_quals _LIBCUDACXX_NODEBUG_TYPE =
__tuple_types<typename _ApplyFn::template __apply<__type_at_c<_Idx, __tuple_types_list>>...>;
__tuple_types<__type_call<_ApplyFn, __type_at_c<_Idx, __tuple_types_list>>...>;
};

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, class _ApplyFn = __apply_cvref_fn<_Tp>>
using __apply_quals = __tuple_types<__type_call<_ApplyFn, __value_type<_Idx>>...>;
};

template <class _Tp,
Expand Down
83 changes: 0 additions & 83 deletions libcudacxx/include/cuda/std/__type_traits/apply_cv.h

This file was deleted.

12 changes: 4 additions & 8 deletions libcudacxx/include/cuda/std/__type_traits/common_reference.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,13 +76,9 @@ using __cond_res = decltype(false ? _CUDA_VSTD::declval<_Xp (&)()>()() : _CUDA_V
// Let `XREF(A)` denote a unary alias template `T` such that `T<U>` denotes the same type as `U`
// with the addition of `A`'s cv and reference qualifiers, for a non-reference cv-unqualified type
// `U`.
// [Note: `XREF(A)` is `__xref<A>::template __apply`]
// [Note: `XREF(A)` is `__xref<A>::template __call`]
template <class _Tp>
struct __xref
{
template <class _Up>
using __apply = __copy_cvref_t<_Tp, _Up>;
};
using __xref = __apply_cvref_fn<_Tp>;

// Given types A and B, let X be remove_reference_t<A>, let Y be remove_reference_t<B>,
// and let COMMON-REF(A, B) be:
Expand Down Expand Up @@ -220,8 +216,8 @@ template <class _Tp, class _Up>
using __basic_common_reference_t =
typename basic_common_reference<remove_cvref_t<_Tp>,
remove_cvref_t<_Up>,
__xref<_Tp>::template __apply,
__xref<_Up>::template __apply>::type;
__xref<_Tp>::template __call,
__xref<_Up>::template __call>::type;

template <class _Tp, class _Up>
struct __common_reference_sub_bullet2<_Tp, _Up, void_t<__basic_common_reference_t<_Tp, _Up>>>
Expand Down
Loading

0 comments on commit 932ab54

Please sign in to comment.