Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace typedef with using in libcu++ #3368

Merged
merged 18 commits into from
Jan 15, 2025
16 changes: 8 additions & 8 deletions libcudacxx/examples/trie.cu
Original file line number Diff line number Diff line change
Expand Up @@ -149,19 +149,19 @@ inline void assert_(cudaError_t code, const char* file, int line)
template <class T>
struct managed_allocator
{
typedef cuda::std::size_t size_type;
typedef cuda::std::ptrdiff_t difference_type;
using size_type = cuda::std::size_t;
using difference_type = cuda::std::ptrdiff_t;

typedef T value_type;
typedef T* pointer; // (deprecated in C++17)(removed in C++20) T*
typedef const T* const_pointer; // (deprecated in C++17)(removed in C++20) const T*
typedef T& reference; // (deprecated in C++17)(removed in C++20) T&
typedef const T& const_reference; // (deprecated in C++17)(removed in C++20) const T&
using value_type = T;
using pointer = T*; // (deprecated in C++17)(removed in C++20) T*
using const_pointer = const T*; // (deprecated in C++17)(removed in C++20) const T*
using reference = T&; // (deprecated in C++17)(removed in C++20) T&
using const_reference = const T&; // (deprecated in C++17)(removed in C++20) const T&

template <class U>
struct rebind
{
typedef managed_allocator<U> other;
using other = managed_allocator<U>;
};
managed_allocator() = default;
template <class U>
Expand Down
4 changes: 2 additions & 2 deletions libcudacxx/include/cuda/std/__algorithm/for_each_n.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ template <class _InputIterator, class _Size, class _Function>
_LIBCUDACXX_HIDE_FROM_ABI _CCCL_CONSTEXPR_CXX14 _InputIterator
for_each_n(_InputIterator __first, _Size __orig_n, _Function __f)
{
typedef decltype(_CUDA_VSTD::__convert_to_integral(__orig_n)) _IntegralSize;
_IntegralSize __n = __orig_n;
using _IntegralSize = decltype(_CUDA_VSTD::__convert_to_integral(__orig_n));
_IntegralSize __n = __orig_n;
while (__n > 0)
{
__f(*__first);
Expand Down
2 changes: 1 addition & 1 deletion libcudacxx/include/cuda/std/__algorithm/is_heap_until.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ template <class _Compare, class _RandomAccessIterator>
_LIBCUDACXX_HIDE_FROM_ABI _CCCL_CONSTEXPR_CXX14 _RandomAccessIterator
__is_heap_until(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare&& __comp)
{
typedef typename iterator_traits<_RandomAccessIterator>::difference_type difference_type;
using difference_type = typename iterator_traits<_RandomAccessIterator>::difference_type;
difference_type __len = __last - __first;
difference_type __p = 0;
difference_type __c = 1;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ template <class _ForwardIterator, class _Predicate>
_LIBCUDACXX_HIDE_FROM_ABI _CCCL_CONSTEXPR_CXX14 _ForwardIterator
partition_point(_ForwardIterator __first, _ForwardIterator __last, _Predicate __pred)
{
typedef typename iterator_traits<_ForwardIterator>::difference_type difference_type;
using difference_type = typename iterator_traits<_ForwardIterator>::difference_type;
difference_type __len = _CUDA_VSTD::distance(__first, __last);
while (__len != 0)
{
Expand Down
20 changes: 10 additions & 10 deletions libcudacxx/include/cuda/std/__algorithm/rotate.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ template <class _AlgPolicy, class _ForwardIterator>
_LIBCUDACXX_HIDE_FROM_ABI _CCCL_CONSTEXPR_CXX14 _ForwardIterator
__rotate_left(_ForwardIterator __first, _ForwardIterator __last)
{
typedef typename iterator_traits<_ForwardIterator>::value_type value_type;
using _Ops = _IterOps<_AlgPolicy>;
using value_type = typename iterator_traits<_ForwardIterator>::value_type;
using _Ops = _IterOps<_AlgPolicy>;

value_type __tmp = _Ops::__iter_move(__first);
_ForwardIterator __lm1 = _CUDA_VSTD::__move<_AlgPolicy>(_Ops::next(__first), __last, __first).second;
Expand All @@ -48,8 +48,8 @@ template <class _AlgPolicy, class _BidirectionalIterator>
_LIBCUDACXX_HIDE_FROM_ABI _CCCL_CONSTEXPR_CXX14 _BidirectionalIterator
__rotate_right(_BidirectionalIterator __first, _BidirectionalIterator __last)
{
typedef typename iterator_traits<_BidirectionalIterator>::value_type value_type;
using _Ops = _IterOps<_AlgPolicy>;
using value_type = typename iterator_traits<_BidirectionalIterator>::value_type;
using _Ops = _IterOps<_AlgPolicy>;

_BidirectionalIterator __lm1 = _Ops::prev(__last);
value_type __tmp = _Ops::__iter_move(__lm1);
Expand Down Expand Up @@ -118,9 +118,9 @@ template <class _AlgPolicy, typename _RandomAccessIterator>
_LIBCUDACXX_HIDE_FROM_ABI _CCCL_CONSTEXPR_CXX14 _RandomAccessIterator
__rotate_gcd(_RandomAccessIterator __first, _RandomAccessIterator __middle, _RandomAccessIterator __last)
{
typedef typename iterator_traits<_RandomAccessIterator>::difference_type difference_type;
typedef typename iterator_traits<_RandomAccessIterator>::value_type value_type;
using _Ops = _IterOps<_AlgPolicy>;
using difference_type = typename iterator_traits<_RandomAccessIterator>::difference_type;
using value_type = typename iterator_traits<_RandomAccessIterator>::value_type;
using _Ops = _IterOps<_AlgPolicy>;

const difference_type __m1 = __middle - __first;
const difference_type __m2 = _Ops::distance(__middle, __last);
Expand Down Expand Up @@ -158,7 +158,7 @@ template <class _AlgPolicy, class _ForwardIterator>
_LIBCUDACXX_HIDE_FROM_ABI _CCCL_CONSTEXPR_CXX14 _ForwardIterator __rotate_impl(
_ForwardIterator __first, _ForwardIterator __middle, _ForwardIterator __last, _CUDA_VSTD::forward_iterator_tag)
{
typedef typename iterator_traits<_ForwardIterator>::value_type value_type;
using value_type = typename iterator_traits<_ForwardIterator>::value_type;
if (_CCCL_TRAIT(is_trivially_move_assignable, value_type))
{
if (_IterOps<_AlgPolicy>::next(__first) == __middle)
Expand All @@ -176,7 +176,7 @@ _LIBCUDACXX_HIDE_FROM_ABI _CCCL_CONSTEXPR_CXX14 _BidirectionalIterator __rotate_
_BidirectionalIterator __last,
bidirectional_iterator_tag)
{
typedef typename iterator_traits<_BidirectionalIterator>::value_type value_type;
using value_type = typename iterator_traits<_BidirectionalIterator>::value_type;
if (_CCCL_TRAIT(is_trivially_move_assignable, value_type))
{
if (_IterOps<_AlgPolicy>::next(__first) == __middle)
Expand All @@ -198,7 +198,7 @@ _LIBCUDACXX_HIDE_FROM_ABI _CCCL_CONSTEXPR_CXX14 _RandomAccessIterator __rotate_i
_RandomAccessIterator __last,
random_access_iterator_tag)
{
typedef typename iterator_traits<_RandomAccessIterator>::value_type value_type;
using value_type = typename iterator_traits<_RandomAccessIterator>::value_type;
if (_CCCL_TRAIT(is_trivially_move_assignable, value_type))
{
if (_IterOps<_AlgPolicy>::next(__first) == __middle)
Expand Down
4 changes: 2 additions & 2 deletions libcudacxx/include/cuda/std/__algorithm/search.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,8 @@ __search(_RandomAccessIterator1 __first1,
random_access_iterator_tag,
random_access_iterator_tag)
{
typedef typename iterator_traits<_RandomAccessIterator1>::difference_type _Diff1;
typedef typename iterator_traits<_RandomAccessIterator2>::difference_type _Diff2;
using _Diff1 = typename iterator_traits<_RandomAccessIterator1>::difference_type;
using _Diff2 = typename iterator_traits<_RandomAccessIterator2>::difference_type;
// Take advantage of knowing source and pattern lengths. Stop short when source is smaller than pattern
const _Diff2 __len2 = __last2 - __first2;
if (__len2 == 0)
Expand Down
4 changes: 2 additions & 2 deletions libcudacxx/include/cuda/std/__algorithm/sift_down.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ _LIBCUDACXX_HIDE_FROM_ABI _CCCL_CONSTEXPR_CXX14 void __sift_down(
{
using _Ops = _IterOps<_AlgPolicy>;

typedef typename iterator_traits<_RandomAccessIterator>::difference_type difference_type;
typedef typename iterator_traits<_RandomAccessIterator>::value_type value_type;
using difference_type = typename iterator_traits<_RandomAccessIterator>::difference_type;
using value_type = typename iterator_traits<_RandomAccessIterator>::value_type;
// left-child of __start is at 2 * __start + 1
// right-child of __start is at 2 * __start + 2
difference_type __child = __start - __first;
Expand Down
5 changes: 2 additions & 3 deletions libcudacxx/include/cuda/std/__atomic/order.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,15 +84,14 @@ inline constexpr auto memory_order_seq_cst = memory_order::seq_cst;

#else // ^^^ C++20 ^^^ / vvv C++17 vvv

typedef enum memory_order
{
using memory_order = enum memory_order {
memory_order_relaxed = __mo_relaxed,
memory_order_consume = __mo_consume,
memory_order_acquire = __mo_acquire,
memory_order_release = __mo_release,
memory_order_acq_rel = __mo_acq_rel,
memory_order_seq_cst = __mo_seq_cst,
} memory_order;
};

#endif // _CCCL_STD_VER >= 2020

Expand Down
4 changes: 2 additions & 2 deletions libcudacxx/include/cuda/std/__complex/nvbf16.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,8 @@ struct __type_to_vector<__nv_bfloat16>
template <>
struct __cccl_complex_overload_traits<__nv_bfloat16, false, false>
{
typedef __nv_bfloat16 _ValueType;
typedef complex<__nv_bfloat16> _ComplexType;
using _ValueType = __nv_bfloat16;
using _ComplexType = complex<__nv_bfloat16>;
};

template <class _Tp>
Expand Down
4 changes: 2 additions & 2 deletions libcudacxx/include/cuda/std/__complex/nvfp16.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,8 @@ struct __type_to_vector<__half>
template <>
struct __cccl_complex_overload_traits<__half, false, false>
{
typedef __half _ValueType;
typedef complex<__half> _ComplexType;
using _ValueType = __half;
using _ComplexType = complex<__half>;
};

template <class _Tp>
Expand Down
2 changes: 1 addition & 1 deletion libcudacxx/include/cuda/std/__exception/terminate.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ _CCCL_NORETURN _LIBCUDACXX_HIDE_FROM_ABI void __cccl_terminate() noexcept

#if 0 // Expose once atomic is universally available

typedef void (*terminate_handler)();
using terminate_handler = void (*)();

# ifdef __CUDA_ARCH__
__device__
Expand Down
6 changes: 3 additions & 3 deletions libcudacxx/include/cuda/std/__functional/binary_function.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ _LIBCUDACXX_BEGIN_NAMESPACE_STD
template <class _Arg1, class _Arg2, class _Result>
struct _CCCL_TYPE_VISIBILITY_DEFAULT _LIBCUDACXX_DEPRECATED_IN_CXX11 binary_function
{
typedef _Arg1 first_argument_type;
typedef _Arg2 second_argument_type;
typedef _Result result_type;
using first_argument_type = _Arg1;
using second_argument_type = _Arg2;
using result_type = _Result;
};

#endif // _CCCL_STD_VER <= 2014 || defined(_LIBCUDACXX_ENABLE_CXX17_REMOVED_UNARY_BINARY_FUNCTION)
Expand Down
40 changes: 20 additions & 20 deletions libcudacxx/include/cuda/std/__functional/bind.h
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ template <class _Ti, class... _Uj>
_LIBCUDACXX_HIDE_FROM_ABI enable_if_t<is_bind_expression<_Ti>::value, __invoke_of<_Ti&, _Uj...>>
__mu(_Ti& __ti, tuple<_Uj...>& __uj)
{
typedef __make_tuple_indices_t<sizeof...(_Uj)> __indices;
using __indices = __make_tuple_indices_t<sizeof...(_Uj)>;
return _CUDA_VSTD::__mu_expand(__ti, __uj, __indices());
}

Expand All @@ -133,7 +133,7 @@ struct __mu_return2
template <class _Ti, class _Uj>
struct __mu_return2<true, _Ti, _Uj>
{
typedef __tuple_element_t<is_placeholder<_Ti>::value - 1, _Uj> type;
using type = __tuple_element_t<is_placeholder<_Ti>::value - 1, _Uj>;
};

template <class _Ti, class _Uj>
Expand All @@ -160,13 +160,13 @@ struct __mu_return_impl;
template <bool _Invokable, class _Ti, class... _Uj>
struct __mu_return_invokable // false
{
typedef __nat type;
using type = __nat;
};

template <class _Ti, class... _Uj>
struct __mu_return_invokable<true, _Ti, _Uj...>
{
typedef typename __invoke_of<_Ti&, _Uj...>::type type;
using type = typename __invoke_of<_Ti&, _Uj...>::type;
};

template <class _Ti, class... _Uj>
Expand All @@ -177,19 +177,19 @@ struct __mu_return_impl<_Ti, false, true, false, tuple<_Uj...>>
template <class _Ti, class _TupleUj>
struct __mu_return_impl<_Ti, false, false, true, _TupleUj>
{
typedef __tuple_element_t<is_placeholder<_Ti>::value - 1, _TupleUj>&& type;
using type = __tuple_element_t<is_placeholder<_Ti>::value - 1, _TupleUj>&&;
};

template <class _Ti, class _TupleUj>
struct __mu_return_impl<_Ti, true, false, false, _TupleUj>
{
typedef typename _Ti::type& type;
using type = typename _Ti::type&;
};

template <class _Ti, class _TupleUj>
struct __mu_return_impl<_Ti, false, false, false, _TupleUj>
{
typedef _Ti& type;
using type = _Ti&;
};

template <class _Ti, class _TupleUj>
Expand Down Expand Up @@ -226,13 +226,13 @@ struct __bind_return;
template <class _Fp, class... _BoundArgs, class _TupleUj>
struct __bind_return<_Fp, tuple<_BoundArgs...>, _TupleUj, true>
{
typedef typename __invoke_of<_Fp&, typename __mu_return<_BoundArgs, _TupleUj>::type...>::type type;
using type = typename __invoke_of<_Fp&, typename __mu_return<_BoundArgs, _TupleUj>::type...>::type;
};

template <class _Fp, class... _BoundArgs, class _TupleUj>
struct __bind_return<_Fp, const tuple<_BoundArgs...>, _TupleUj, true>
{
typedef typename __invoke_of<_Fp&, typename __mu_return<const _BoundArgs, _TupleUj>::type...>::type type;
using type = typename __invoke_of<_Fp&, typename __mu_return<const _BoundArgs, _TupleUj>::type...>::type;
};

template <class _Fp, class _BoundArgs, class _TupleUj>
Expand All @@ -249,14 +249,14 @@ template <class _Fp, class... _BoundArgs>
class __bind : public __weak_result_type<decay_t<_Fp>>
{
protected:
typedef decay_t<_Fp> _Fd;
typedef tuple<decay_t<_BoundArgs>...> _Td;
using _Fd = decay_t<_Fp>;
using _Td = tuple<decay_t<_BoundArgs>...>;

private:
_Fd __f_;
_Td __bound_args_;

typedef __make_tuple_indices_t<sizeof...(_BoundArgs)> __indices;
using __indices = __make_tuple_indices_t<sizeof...(_BoundArgs)>;

public:
template <class _Gp,
Expand Down Expand Up @@ -291,12 +291,12 @@ struct is_bind_expression<__bind<_Fp, _BoundArgs...>> : public true_type
template <class _Rp, class _Fp, class... _BoundArgs>
class __bind_r : public __bind<_Fp, _BoundArgs...>
{
typedef __bind<_Fp, _BoundArgs...> base;
typedef typename base::_Fd _Fd;
typedef typename base::_Td _Td;
using base = __bind<_Fp, _BoundArgs...>;
using _Fd = typename base::_Fd;
using _Td = typename base::_Td;

public:
typedef _Rp result_type;
using result_type = _Rp;

template <class _Gp,
class... _BA,
Expand All @@ -311,7 +311,7 @@ class __bind_r : public __bind<_Fp, _BoundArgs...>
result_type>
operator()(_Args&&... __args)
{
typedef __invoke_void_return_wrapper<_Rp> _Invoker;
using _Invoker = __invoke_void_return_wrapper<_Rp>;
return _Invoker::__call(static_cast<base&>(*this), _CUDA_VSTD::forward<_Args>(__args)...);
}

Expand All @@ -321,7 +321,7 @@ class __bind_r : public __bind<_Fp, _BoundArgs...>
result_type>
operator()(_Args&&... __args) const
{
typedef __invoke_void_return_wrapper<_Rp> _Invoker;
using _Invoker = __invoke_void_return_wrapper<_Rp>;
return _Invoker::__call(static_cast<base const&>(*this), _CUDA_VSTD::forward<_Args>(__args)...);
}
};
Expand All @@ -333,15 +333,15 @@ struct is_bind_expression<__bind_r<_Rp, _Fp, _BoundArgs...>> : public true_type
template <class _Fp, class... _BoundArgs>
_LIBCUDACXX_HIDE_FROM_ABI _CCCL_CONSTEXPR_CXX20 __bind<_Fp, _BoundArgs...> bind(_Fp&& __f, _BoundArgs&&... __bound_args)
{
typedef __bind<_Fp, _BoundArgs...> type;
using type = __bind<_Fp, _BoundArgs...>;
return type(_CUDA_VSTD::forward<_Fp>(__f), _CUDA_VSTD::forward<_BoundArgs>(__bound_args)...);
}

template <class _Rp, class _Fp, class... _BoundArgs>
_LIBCUDACXX_HIDE_FROM_ABI _CCCL_CONSTEXPR_CXX20 __bind_r<_Rp, _Fp, _BoundArgs...>
bind(_Fp&& __f, _BoundArgs&&... __bound_args)
{
typedef __bind_r<_Rp, _Fp, _BoundArgs...> type;
using type = __bind_r<_Rp, _Fp, _BoundArgs...>;
return type(_CUDA_VSTD::forward<_Fp>(__f), _CUDA_VSTD::forward<_BoundArgs>(__bound_args)...);
}

Expand Down
Loading
Loading