diff --git a/libcudacxx/include/cuda/std/__mdspan/default_accessor.h b/libcudacxx/include/cuda/std/__mdspan/default_accessor.h index 33bef7cb07..ea0924915d 100644 --- a/libcudacxx/include/cuda/std/__mdspan/default_accessor.h +++ b/libcudacxx/include/cuda/std/__mdspan/default_accessor.h @@ -72,10 +72,9 @@ struct default_accessor __MDSPAN_INLINE_FUNCTION_DEFAULTED constexpr default_accessor() noexcept = default; - __MDSPAN_TEMPLATE_REQUIRES(class _OtherElementType, - /* requires */ (_CCCL_TRAIT(is_convertible, _OtherElementType (*)[], element_type (*)[]))) - __MDSPAN_INLINE_FUNCTION - constexpr default_accessor(default_accessor<_OtherElementType>) noexcept {} + _LIBCUDACXX_TEMPLATE(class _OtherElementType) + _LIBCUDACXX_REQUIRES(_CCCL_TRAIT(is_convertible, _OtherElementType (*)[], element_type (*)[])) + __MDSPAN_INLINE_FUNCTION constexpr default_accessor(default_accessor<_OtherElementType>) noexcept {} __MDSPAN_INLINE_FUNCTION constexpr data_handle_type offset(data_handle_type __p, size_t __i) const noexcept diff --git a/libcudacxx/include/cuda/std/__mdspan/extents.h b/libcudacxx/include/cuda/std/__mdspan/extents.h index 58ab181afc..c8177542da 100644 --- a/libcudacxx/include/cuda/std/__mdspan/extents.h +++ b/libcudacxx/include/cuda/std/__mdspan/extents.h @@ -248,16 +248,13 @@ class extents __MDSPAN_INLINE_FUNCTION_DEFAULTED constexpr extents() noexcept = default; // Converting constructor - __MDSPAN_TEMPLATE_REQUIRES( - class _OtherIndexType, - size_t... _OtherExtents, - /* requires */ - ( - /* multi-stage check to protect from invalid pack expansion when sizes don't match? */ - decltype(__detail::__check_compatible_extents( - integral_constant{}, - _CUDA_VSTD::integer_sequence{}, - _CUDA_VSTD::integer_sequence{}))::value)) + _LIBCUDACXX_TEMPLATE(class _OtherIndexType, size_t... _OtherExtents) + _LIBCUDACXX_REQUIRES( + /* multi-stage check to protect from invalid pack expansion when sizes don't match? */ + (decltype(__detail::__check_compatible_extents( + integral_constant{}, + _CUDA_VSTD::integer_sequence{}, + _CUDA_VSTD::integer_sequence{}))::value)) __MDSPAN_INLINE_FUNCTION __MDSPAN_CONDITIONAL_EXPLICIT( (((_Extents != dynamic_extent) && (_OtherExtents == dynamic_extent)) || ...) @@ -287,23 +284,23 @@ class extents } # ifdef __NVCC__ - __MDSPAN_TEMPLATE_REQUIRES( - class... _Integral, - /* requires */ ( - // TODO: check whether the other version works with newest NVCC, doesn't with 11.4 - // NVCC seems to pick up rank_dynamic from the wrong extents type??? - __MDSPAN_FOLD_AND(_CCCL_TRAIT(_CUDA_VSTD::is_convertible, _Integral, index_type) /* && ... */) - && __MDSPAN_FOLD_AND(_CCCL_TRAIT(_CUDA_VSTD::is_nothrow_constructible, index_type, _Integral) /* && ... */) && - // NVCC chokes on the fold thingy here so wrote the workaround - ((sizeof...(_Integral) == __detail::__count_dynamic_extents<_Extents...>::val) - || (sizeof...(_Integral) == sizeof...(_Extents))))) + _LIBCUDACXX_TEMPLATE(class... _Integral) + _LIBCUDACXX_REQUIRES( + // TODO: check whether the other version works with newest NVCC, doesn't with 11.4 + // NVCC seems to pick up rank_dynamic from the wrong extents type??? + __MDSPAN_FOLD_AND(_CCCL_TRAIT(_CUDA_VSTD::is_convertible, _Integral, index_type) /* && ... */) + _LIBCUDACXX_AND __MDSPAN_FOLD_AND( + _CCCL_TRAIT(_CUDA_VSTD::is_nothrow_constructible, index_type, _Integral) /* && ... */) _LIBCUDACXX_AND + // NVCC chokes on the fold thingy here so wrote the workaround + ((sizeof...(_Integral) == __detail::__count_dynamic_extents<_Extents...>::val) + || (sizeof...(_Integral) == sizeof...(_Extents)))) # else - __MDSPAN_TEMPLATE_REQUIRES( - class... _Integral, - /* requires */ ( - __MDSPAN_FOLD_AND(_CCCL_TRAIT(_CUDA_VSTD::is_convertible, _Integral, index_type) /* && ... */) - && __MDSPAN_FOLD_AND(_CCCL_TRAIT(_CUDA_VSTD::is_nothrow_constructible, index_type, _Integral) /* && ... */) - && ((sizeof...(_Integral) == rank_dynamic()) || (sizeof...(_Integral) == rank())))) + _LIBCUDACXX_TEMPLATE(class... _Integral) + _LIBCUDACXX_REQUIRES( + __MDSPAN_FOLD_AND(_CCCL_TRAIT(_CUDA_VSTD::is_convertible, _Integral, index_type) /* && ... */) + _LIBCUDACXX_AND __MDSPAN_FOLD_AND( + _CCCL_TRAIT(_CUDA_VSTD::is_nothrow_constructible, index_type, _Integral) /* && ... */) + _LIBCUDACXX_AND((sizeof...(_Integral) == rank_dynamic()) || (sizeof...(_Integral) == rank()))) # endif __MDSPAN_INLINE_FUNCTION explicit constexpr extents(_Integral... __exts) noexcept @@ -337,21 +334,16 @@ class extents # ifdef __NVCC__ // NVCC seems to pick up rank_dynamic from the wrong extents type??? // NVCC chokes on the fold thingy here so wrote the workaround - __MDSPAN_TEMPLATE_REQUIRES( - class _IndexType, - size_t _Np, - /* requires */ - (_CCCL_TRAIT(_CUDA_VSTD::is_convertible, _IndexType, index_type) - && _CCCL_TRAIT(_CUDA_VSTD::is_nothrow_constructible, index_type, _IndexType) - && ((_Np == __detail::__count_dynamic_extents<_Extents...>::val) || (_Np == sizeof...(_Extents))))) + _LIBCUDACXX_TEMPLATE(class _IndexType, size_t _Np) + _LIBCUDACXX_REQUIRES( + _CCCL_TRAIT(_CUDA_VSTD::is_convertible, _IndexType, index_type) + _LIBCUDACXX_AND _CCCL_TRAIT(_CUDA_VSTD::is_nothrow_constructible, index_type, _IndexType) + _LIBCUDACXX_AND((_Np == __detail::__count_dynamic_extents<_Extents...>::val) || (_Np == sizeof...(_Extents)))) # else - __MDSPAN_TEMPLATE_REQUIRES( - class _IndexType, - size_t _Np, - /* requires */ - (_CCCL_TRAIT(_CUDA_VSTD::is_convertible, _IndexType, index_type) - && _CCCL_TRAIT(_CUDA_VSTD::is_nothrow_constructible, index_type, _IndexType) - && (_Np == rank() || _Np == rank_dynamic()))) + _LIBCUDACXX_TEMPLATE(class _IndexType, size_t _Np) + _LIBCUDACXX_REQUIRES(_CCCL_TRAIT(_CUDA_VSTD::is_convertible, _IndexType, index_type) + _LIBCUDACXX_AND _CCCL_TRAIT(_CUDA_VSTD::is_nothrow_constructible, index_type, _IndexType) + _LIBCUDACXX_AND(_Np == rank() || _Np == rank_dynamic())) # endif __MDSPAN_CONDITIONAL_EXPLICIT(_Np != rank_dynamic()) __MDSPAN_INLINE_FUNCTION @@ -386,21 +378,16 @@ class extents # ifdef __NVCC__ // NVCC seems to pick up rank_dynamic from the wrong extents type??? // NVCC chokes on the fold thingy here so wrote the workaround - __MDSPAN_TEMPLATE_REQUIRES( - class _IndexType, - size_t _Np, - /* requires */ - (_CCCL_TRAIT(_CUDA_VSTD::is_convertible, _IndexType, index_type) - && _CCCL_TRAIT(_CUDA_VSTD::is_nothrow_constructible, index_type, _IndexType) - && ((_Np == __detail::__count_dynamic_extents<_Extents...>::val) || (_Np == sizeof...(_Extents))))) + _LIBCUDACXX_TEMPLATE(class _IndexType, size_t _Np) + _LIBCUDACXX_REQUIRES( + _CCCL_TRAIT(_CUDA_VSTD::is_convertible, _IndexType, index_type) + _LIBCUDACXX_AND _CCCL_TRAIT(_CUDA_VSTD::is_nothrow_constructible, index_type, _IndexType) + _LIBCUDACXX_AND((_Np == __detail::__count_dynamic_extents<_Extents...>::val) || (_Np == sizeof...(_Extents)))) # else - __MDSPAN_TEMPLATE_REQUIRES( - class _IndexType, - size_t _Np, - /* requires */ - (_CCCL_TRAIT(_CUDA_VSTD::is_convertible, _IndexType, index_type) - && _CCCL_TRAIT(_CUDA_VSTD::is_nothrow_constructible, index_type, _IndexType) - && (_Np == rank() || _Np == rank_dynamic()))) + _LIBCUDACXX_TEMPLATE(class _IndexType, size_t _Np) + _LIBCUDACXX_REQUIRES(_CCCL_TRAIT(_CUDA_VSTD::is_convertible, _IndexType, index_type) + _LIBCUDACXX_AND _CCCL_TRAIT(_CUDA_VSTD::is_nothrow_constructible, index_type, _IndexType) + _LIBCUDACXX_AND(_Np == rank() || _Np == rank_dynamic())) # endif __MDSPAN_CONDITIONAL_EXPLICIT(_Np != rank_dynamic()) __MDSPAN_INLINE_FUNCTION diff --git a/libcudacxx/include/cuda/std/__mdspan/layout_left.h b/libcudacxx/include/cuda/std/__mdspan/layout_left.h index b0cdde455c..9d0842515c 100644 --- a/libcudacxx/include/cuda/std/__mdspan/layout_left.h +++ b/libcudacxx/include/cuda/std/__mdspan/layout_left.h @@ -121,8 +121,8 @@ class layout_left::mapping : __extents(__exts) {} - __MDSPAN_TEMPLATE_REQUIRES(class _OtherExtents, - /* requires */ (_CCCL_TRAIT(_CUDA_VSTD::is_constructible, extents_type, _OtherExtents))) + _LIBCUDACXX_TEMPLATE(class _OtherExtents) + _LIBCUDACXX_REQUIRES(_CCCL_TRAIT(_CUDA_VSTD::is_constructible, extents_type, _OtherExtents)) __MDSPAN_CONDITIONAL_EXPLICIT((!_CUDA_VSTD::is_convertible<_OtherExtents, extents_type>::value)) // needs two () due // to comma __MDSPAN_INLINE_FUNCTION constexpr mapping( @@ -135,9 +135,9 @@ class layout_left::mapping */ } - __MDSPAN_TEMPLATE_REQUIRES(class _OtherExtents, - /* requires */ (_CCCL_TRAIT(_CUDA_VSTD::is_constructible, extents_type, _OtherExtents) - && (extents_type::rank() <= 1))) + _LIBCUDACXX_TEMPLATE(class _OtherExtents) + _LIBCUDACXX_REQUIRES(_CCCL_TRAIT(_CUDA_VSTD::is_constructible, extents_type, _OtherExtents) + _LIBCUDACXX_AND(extents_type::rank() <= 1)) __MDSPAN_CONDITIONAL_EXPLICIT((!_CUDA_VSTD::is_convertible<_OtherExtents, extents_type>::value)) // needs two () due // to comma __MDSPAN_INLINE_FUNCTION constexpr mapping( @@ -150,8 +150,8 @@ class layout_left::mapping */ } - __MDSPAN_TEMPLATE_REQUIRES(class _OtherExtents, - /* requires */ (_CCCL_TRAIT(_CUDA_VSTD::is_constructible, extents_type, _OtherExtents))) + _LIBCUDACXX_TEMPLATE(class _OtherExtents) + _LIBCUDACXX_REQUIRES(_CCCL_TRAIT(_CUDA_VSTD::is_constructible, extents_type, _OtherExtents)) __MDSPAN_CONDITIONAL_EXPLICIT((extents_type::rank() > 0)) __MDSPAN_INLINE_FUNCTION constexpr mapping( layout_stride::mapping<_OtherExtents> const& __other) // NOLINT(google-explicit-constructor) @@ -190,11 +190,10 @@ class layout_left::mapping //-------------------------------------------------------------------------------- - __MDSPAN_TEMPLATE_REQUIRES( - class... _Indices, - /* requires */ ((sizeof...(_Indices) == extents_type::rank()) - && __MDSPAN_FOLD_AND((_CCCL_TRAIT(_CUDA_VSTD::is_convertible, _Indices, index_type) - && _CCCL_TRAIT(_CUDA_VSTD::is_nothrow_constructible, index_type, _Indices))))) + _LIBCUDACXX_TEMPLATE(class... _Indices) + _LIBCUDACXX_REQUIRES((sizeof...(_Indices) == extents_type::rank()) _LIBCUDACXX_AND __MDSPAN_FOLD_AND( + (_CCCL_TRAIT(_CUDA_VSTD::is_convertible, _Indices, index_type) + && _CCCL_TRAIT(_CUDA_VSTD::is_nothrow_constructible, index_type, _Indices)))) _CCCL_HOST_DEVICE constexpr index_type operator()(_Indices... __idxs) const noexcept { // Immediately cast incoming indices to `index_type` @@ -227,8 +226,8 @@ class layout_left::mapping return true; } - __MDSPAN_TEMPLATE_REQUIRES(class _Ext = _Extents, - /* requires */ (_Ext::rank() > 0)) + _LIBCUDACXX_TEMPLATE(class _Ext = _Extents) + _LIBCUDACXX_REQUIRES((_Ext::rank() > 0)) __MDSPAN_INLINE_FUNCTION constexpr index_type stride(rank_type __i) const noexcept { diff --git a/libcudacxx/include/cuda/std/__mdspan/layout_right.h b/libcudacxx/include/cuda/std/__mdspan/layout_right.h index efe215f114..4dfd4a1e38 100644 --- a/libcudacxx/include/cuda/std/__mdspan/layout_right.h +++ b/libcudacxx/include/cuda/std/__mdspan/layout_right.h @@ -126,8 +126,8 @@ class layout_right::mapping : __extents(__exts) {} - __MDSPAN_TEMPLATE_REQUIRES(class _OtherExtents, - /* requires */ (_CCCL_TRAIT(_CUDA_VSTD::is_constructible, extents_type, _OtherExtents))) + _LIBCUDACXX_TEMPLATE(class _OtherExtents) + _LIBCUDACXX_REQUIRES(_CCCL_TRAIT(_CUDA_VSTD::is_constructible, extents_type, _OtherExtents)) __MDSPAN_CONDITIONAL_EXPLICIT((!_CUDA_VSTD::is_convertible<_OtherExtents, extents_type>::value)) // needs two () due // to comma __MDSPAN_INLINE_FUNCTION constexpr mapping( @@ -140,9 +140,9 @@ class layout_right::mapping */ } - __MDSPAN_TEMPLATE_REQUIRES(class _OtherExtents, - /* requires */ (_CCCL_TRAIT(_CUDA_VSTD::is_constructible, extents_type, _OtherExtents) - && (extents_type::rank() <= 1))) + _LIBCUDACXX_TEMPLATE(class _OtherExtents) + _LIBCUDACXX_REQUIRES(_CCCL_TRAIT(_CUDA_VSTD::is_constructible, extents_type, _OtherExtents) + _LIBCUDACXX_AND(extents_type::rank() <= 1)) __MDSPAN_CONDITIONAL_EXPLICIT((!_CUDA_VSTD::is_convertible<_OtherExtents, extents_type>::value)) // needs two () due // to comma __MDSPAN_INLINE_FUNCTION constexpr mapping( @@ -155,8 +155,8 @@ class layout_right::mapping */ } - __MDSPAN_TEMPLATE_REQUIRES(class _OtherExtents, - /* requires */ (_CCCL_TRAIT(_CUDA_VSTD::is_constructible, extents_type, _OtherExtents))) + _LIBCUDACXX_TEMPLATE(class _OtherExtents) + _LIBCUDACXX_REQUIRES(_CCCL_TRAIT(_CUDA_VSTD::is_constructible, extents_type, _OtherExtents)) __MDSPAN_CONDITIONAL_EXPLICIT((extents_type::rank() > 0)) __MDSPAN_INLINE_FUNCTION constexpr mapping( layout_stride::mapping<_OtherExtents> const& __other) // NOLINT(google-explicit-constructor) @@ -195,11 +195,10 @@ class layout_right::mapping //-------------------------------------------------------------------------------- - __MDSPAN_TEMPLATE_REQUIRES( - class... _Indices, - /* requires */ ((sizeof...(_Indices) == extents_type::rank()) - && __MDSPAN_FOLD_AND((_CCCL_TRAIT(_CUDA_VSTD::is_convertible, _Indices, index_type) - && _CCCL_TRAIT(_CUDA_VSTD::is_nothrow_constructible, index_type, _Indices))))) + _LIBCUDACXX_TEMPLATE(class... _Indices) + _LIBCUDACXX_REQUIRES((sizeof...(_Indices) == extents_type::rank()) _LIBCUDACXX_AND __MDSPAN_FOLD_AND( + (_CCCL_TRAIT(_CUDA_VSTD::is_convertible, _Indices, index_type) + && _CCCL_TRAIT(_CUDA_VSTD::is_nothrow_constructible, index_type, _Indices)))) _CCCL_HOST_DEVICE constexpr index_type operator()(_Indices... __idxs) const noexcept { return __compute_offset(__rank_count<0, extents_type::rank()>(), static_cast(__idxs)...); @@ -230,8 +229,8 @@ class layout_right::mapping return true; } - __MDSPAN_TEMPLATE_REQUIRES(class _Ext = _Extents, - /* requires */ (_Ext::rank() > 0)) + _LIBCUDACXX_TEMPLATE(class _Ext = _Extents) + _LIBCUDACXX_REQUIRES((_Ext::rank() > 0)) __MDSPAN_INLINE_FUNCTION constexpr index_type stride(rank_type __i) const noexcept { diff --git a/libcudacxx/include/cuda/std/__mdspan/layout_stride.h b/libcudacxx/include/cuda/std/__mdspan/layout_stride.h index 1818adff8a..d0a1ecad4b 100644 --- a/libcudacxx/include/cuda/std/__mdspan/layout_stride.h +++ b/libcudacxx/include/cuda/std/__mdspan/layout_stride.h @@ -93,8 +93,8 @@ struct layout_right namespace __detail { template -constexpr bool __is_mapping_of = - _CUDA_VSTD::is_same, _Mapping>::value; +_LIBCUDACXX_INLINE_VAR constexpr bool __is_mapping_of = + is_same, _Mapping>::value; # if __MDSPAN_USE_CONCEPTS && __MDSPAN_HAS_CXX_20 template @@ -298,17 +298,13 @@ struct layout_stride __MDSPAN_INLINE_FUNCTION_DEFAULTED constexpr mapping() noexcept = default; __MDSPAN_INLINE_FUNCTION_DEFAULTED constexpr mapping(mapping const&) noexcept = default; - __MDSPAN_TEMPLATE_REQUIRES( + // nvcc cannot deduce this constructor when using _LIBCUDACXX_REQUIRES + template < class _IntegralTypes, - /* requires */ ( - // MSVC 19.32 does not like using index_type here, requires the typename _Extents::index_type - // error C2641: cannot deduce template arguments for '_CUDA_VSTD::layout_stride::mapping' - _CCCL_TRAIT(_CUDA_VSTD::is_convertible, const remove_const_t<_IntegralTypes>&, typename _Extents::index_type) - && _CCCL_TRAIT( - _CUDA_VSTD::is_nothrow_constructible, typename _Extents::index_type, const remove_const_t<_IntegralTypes>&))) - __MDSPAN_INLINE_FUNCTION - constexpr mapping(extents_type const& __e, - _CUDA_VSTD::array<_IntegralTypes, extents_type::rank()> const& __s) noexcept + enable_if_t<_CCCL_TRAIT(is_convertible, const remove_const_t<_IntegralTypes>&, index_type), int> = 0, + enable_if_t<_CCCL_TRAIT(is_nothrow_constructible, index_type, const remove_const_t<_IntegralTypes>&), int> = 0> + __MDSPAN_INLINE_FUNCTION constexpr mapping( + extents_type const& __e, _CUDA_VSTD::array<_IntegralTypes, extents_type::rank()> const& __s) noexcept # ifndef _CCCL_HAS_NO_ATTRIBUTE_NO_UNIQUE_ADDRESS : __members{ # else @@ -331,17 +327,13 @@ struct layout_stride */ } - __MDSPAN_TEMPLATE_REQUIRES( + // nvcc cannot deduce this constructor when using _LIBCUDACXX_REQUIRES + template < class _IntegralTypes, - /* requires */ ( - // MSVC 19.32 does not like using index_type here, requires the typename _Extents::index_type - // error C2641: cannot deduce template arguments for '_CUDA_VSTD::layout_stride::mapping' - _CCCL_TRAIT(_CUDA_VSTD::is_convertible, const remove_const_t<_IntegralTypes>&, typename _Extents::index_type) - && _CCCL_TRAIT( - _CUDA_VSTD::is_nothrow_constructible, typename _Extents::index_type, const remove_const_t<_IntegralTypes>&))) - __MDSPAN_INLINE_FUNCTION - constexpr mapping(extents_type const& __e, - _CUDA_VSTD::span<_IntegralTypes, extents_type::rank()> const& __s) noexcept + enable_if_t<_CCCL_TRAIT(is_convertible, const remove_const_t<_IntegralTypes>&, index_type), int> = 0, + enable_if_t<_CCCL_TRAIT(is_nothrow_constructible, index_type, const remove_const_t<_IntegralTypes>&), int> = 0> + __MDSPAN_INLINE_FUNCTION constexpr mapping( + extents_type const& __e, _CUDA_VSTD::span<_IntegralTypes, extents_type::rank()> const& __s) noexcept # ifndef _CCCL_HAS_NO_ATTRIBUTE_NO_UNIQUE_ADDRESS : __members{ # else @@ -365,25 +357,25 @@ struct layout_stride } # if !(__MDSPAN_USE_CONCEPTS && __MDSPAN_HAS_CXX_20) - __MDSPAN_TEMPLATE_REQUIRES( - class _StridedLayoutMapping, - /* requires */ ( - _CCCL_TRAIT(_CUDA_VSTD::is_constructible, extents_type, typename _StridedLayoutMapping::extents_type) - && __detail::__is_mapping_of - && _StridedLayoutMapping::is_always_unique() && _StridedLayoutMapping::is_always_strided())) + _LIBCUDACXX_TEMPLATE(class _StridedLayoutMapping) + _LIBCUDACXX_REQUIRES( + _CCCL_TRAIT(_CUDA_VSTD::is_constructible, extents_type, typename _StridedLayoutMapping::extents_type) + _LIBCUDACXX_AND __detail::__is_mapping_of + _LIBCUDACXX_AND(_StridedLayoutMapping::is_always_unique()) + _LIBCUDACXX_AND(_StridedLayoutMapping::is_always_strided())) # else template requires(__detail::__layout_mapping_alike<_StridedLayoutMapping> - && _CCCL_TRAIT(_CUDA_VSTD::is_constructible, extents_type, typename _StridedLayoutMapping::extents_type) + && _CCCL_TRAIT(is_constructible, extents_type, typename _StridedLayoutMapping::extents_type) && _StridedLayoutMapping::is_always_unique() && _StridedLayoutMapping::is_always_strided()) # endif __MDSPAN_CONDITIONAL_EXPLICIT( - (!_CUDA_VSTD::is_convertible::value) + (!is_convertible::value) && (__detail::__is_mapping_of || __detail::__is_mapping_of || __detail::__is_mapping_of) ) // needs two () due to comma - __MDSPAN_INLINE_FUNCTION constexpr mapping( - _StridedLayoutMapping const& __other) noexcept // NOLINT(google-explicit-constructor) + __MDSPAN_INLINE_FUNCTION + constexpr mapping(_StridedLayoutMapping const& __other) noexcept // NOLINT(google-explicit-constructor) # ifndef _CCCL_HAS_NO_ATTRIBUTE_NO_UNIQUE_ADDRESS : __members{ # else @@ -440,12 +432,11 @@ struct layout_stride return __span_size; } - __MDSPAN_TEMPLATE_REQUIRES( - class... _Indices, - /* requires */ ( - sizeof...(_Indices) == _Extents::rank() - && __MDSPAN_FOLD_AND(_CCCL_TRAIT(_CUDA_VSTD::is_convertible, _Indices, index_type) /*&& ...*/) - && __MDSPAN_FOLD_AND(_CCCL_TRAIT(_CUDA_VSTD::is_nothrow_constructible, index_type, _Indices) /*&& ...*/))) + _LIBCUDACXX_TEMPLATE(class... _Indices) + _LIBCUDACXX_REQUIRES( + (sizeof...(_Indices) == _Extents::rank()) + _LIBCUDACXX_AND __MDSPAN_FOLD_AND(_CCCL_TRAIT(is_convertible, _Indices, index_type) /*&& ...*/) + _LIBCUDACXX_AND __MDSPAN_FOLD_AND(_CCCL_TRAIT(is_nothrow_constructible, index_type, _Indices) /*&& ...*/)) __MDSPAN_FORCE_INLINE_FUNCTION constexpr index_type operator()(_Indices... __idxs) const noexcept { @@ -480,8 +471,8 @@ struct layout_stride return true; } - __MDSPAN_TEMPLATE_REQUIRES(class _Ext = _Extents, - /* requires */ (_Ext::rank() > 0)) + _LIBCUDACXX_TEMPLATE(class _Ext = _Extents) + _LIBCUDACXX_REQUIRES((_Ext::rank() > 0)) __MDSPAN_INLINE_FUNCTION constexpr index_type stride(rank_type __r) const noexcept { @@ -489,11 +480,11 @@ struct layout_stride } # if !(__MDSPAN_USE_CONCEPTS && __MDSPAN_HAS_CXX_20) - __MDSPAN_TEMPLATE_REQUIRES( - class _StridedLayoutMapping, - /* requires */ (__detail::__is_mapping_of - && (extents_type::rank() == _StridedLayoutMapping::extents_type::rank()) - && _StridedLayoutMapping::is_always_strided())) + _LIBCUDACXX_TEMPLATE(class _StridedLayoutMapping) + _LIBCUDACXX_REQUIRES( + __detail::__is_mapping_of _LIBCUDACXX_AND( + extents_type::rank() == _StridedLayoutMapping::extents_type::rank()) + _LIBCUDACXX_AND(_StridedLayoutMapping::is_always_strided())) # else template requires( @@ -515,30 +506,30 @@ struct layout_stride } // This one is not technically part of the proposal. Just here to make implementation a bit more optimal hopefully - __MDSPAN_TEMPLATE_REQUIRES(class _OtherExtents, - /* requires */ ((extents_type::rank() == _OtherExtents::rank()))) - __MDSPAN_INLINE_FUNCTION - friend constexpr bool operator==(mapping const& __lhs, mapping<_OtherExtents> const& __rhs) noexcept + _LIBCUDACXX_TEMPLATE(class _OtherExtents) + _LIBCUDACXX_REQUIRES((extents_type::rank() == _OtherExtents::rank())) + __MDSPAN_INLINE_FUNCTION friend constexpr bool + operator==(mapping const& __lhs, mapping<_OtherExtents> const& __rhs) noexcept { return __impl::_eq_impl(__lhs, __rhs); } # if !__MDSPAN_HAS_CXX_20 - __MDSPAN_TEMPLATE_REQUIRES( - class _StridedLayoutMapping, - /* requires */ (__detail::__is_mapping_of - && (extents_type::rank() == _StridedLayoutMapping::extents_type::rank()) - && _StridedLayoutMapping::is_always_strided())) - __MDSPAN_INLINE_FUNCTION - friend constexpr bool operator!=(const mapping& __x, const _StridedLayoutMapping& __y) noexcept + _LIBCUDACXX_TEMPLATE(class _StridedLayoutMapping) + _LIBCUDACXX_REQUIRES( + __detail::__is_mapping_of _LIBCUDACXX_AND( + extents_type::rank() == _StridedLayoutMapping::extents_type::rank()) + _LIBCUDACXX_AND(_StridedLayoutMapping::is_always_strided())) + __MDSPAN_INLINE_FUNCTION friend constexpr bool + operator!=(const mapping& __x, const _StridedLayoutMapping& __y) noexcept { return not(__x == __y); } - __MDSPAN_TEMPLATE_REQUIRES(class _OtherExtents, - /* requires */ ((extents_type::rank() == _OtherExtents::rank()))) - __MDSPAN_INLINE_FUNCTION - friend constexpr bool operator!=(mapping const& __lhs, mapping<_OtherExtents> const& __rhs) noexcept + _LIBCUDACXX_TEMPLATE(class _OtherExtents) + _LIBCUDACXX_REQUIRES((extents_type::rank() == _OtherExtents::rank())) + __MDSPAN_INLINE_FUNCTION friend constexpr bool + operator!=(mapping const& __lhs, mapping<_OtherExtents> const& __rhs) noexcept { return __impl::_not_eq_impl(__lhs, __rhs); } diff --git a/libcudacxx/include/cuda/std/__mdspan/macros.h b/libcudacxx/include/cuda/std/__mdspan/macros.h index 0eba30a718..0aa54e0330 100644 --- a/libcudacxx/include/cuda/std/__mdspan/macros.h +++ b/libcudacxx/include/cuda/std/__mdspan/macros.h @@ -54,6 +54,7 @@ # pragma system_header #endif // no system header +#include #include #include #include @@ -249,167 +250,6 @@ // end Preprocessor helpers }}}1 //============================================================================== -//============================================================================== -// {{{1 - -// These compatibility macros don't help with partial ordering, but they should do the trick -// for what we need to do with concepts in mdspan -# ifdef __MDSPAN_USE_CONCEPTS -# define __MDSPAN_CLOSE_ANGLE_REQUIRES(REQ) \ - > \ - requires REQ -# define __MDSPAN_FUNCTION_REQUIRES(PAREN_PREQUALS, FNAME, PAREN_PARAMS, QUALS, REQ) \ - __MDSPAN_PP_REMOVE_PARENS(PAREN_PREQUALS) \ - FNAME PAREN_PARAMS QUALS \ - requires REQ /**/ -# else -# define __MDSPAN_CLOSE_ANGLE_REQUIRES(REQ) , typename _CUDA_VSTD::enable_if<(REQ), int>::type = 0 > -# define __MDSPAN_FUNCTION_REQUIRES(PAREN_PREQUALS, FNAME, PAREN_PARAMS, QUALS, REQ) \ - __MDSPAN_TEMPLATE_REQUIRES( \ - class __function_requires_ignored = void, (_CUDA_VSTD::is_void<__function_requires_ignored>::value && REQ)) \ - __MDSPAN_PP_REMOVE_PARENS(PAREN_PREQUALS) FNAME PAREN_PARAMS QUALS /**/ -# endif - -# if defined(__MDSPAN_COMPILER_MSVC) -# define __MDSPAN_TEMPLATE_REQUIRES(...) \ - __MDSPAN_PP_CAT(__MDSPAN_PP_CAT(__MDSPAN_TEMPLATE_REQUIRES_, __MDSPAN_PP_COUNT(__VA_ARGS__))(__VA_ARGS__), ) \ - /**/ -# else -# define __MDSPAN_TEMPLATE_REQUIRES(...) \ - __MDSPAN_PP_EVAL(__MDSPAN_PP_CAT(__MDSPAN_TEMPLATE_REQUIRES_, __MDSPAN_PP_COUNT(__VA_ARGS__)), __VA_ARGS__) \ - /**/ -# endif - -# define __MDSPAN_TEMPLATE_REQUIRES_2(TP1, REQ) template end Concept emulation }}}1 -//============================================================================== - //============================================================================== // {{{1 diff --git a/libcudacxx/include/cuda/std/__mdspan/mdspan.h b/libcudacxx/include/cuda/std/__mdspan/mdspan.h index 1103663025..27e6a57a94 100644 --- a/libcudacxx/include/cuda/std/__mdspan/mdspan.h +++ b/libcudacxx/include/cuda/std/__mdspan/mdspan.h @@ -168,22 +168,21 @@ class mdspan __MDSPAN_INLINE_FUNCTION_DEFAULTED constexpr mdspan() requires( // Directly using rank_dynamic()>0 here doesn't work for nvcc - (extents_type::rank_dynamic() > 0) && _CCCL_TRAIT(_CUDA_VSTD::is_default_constructible, data_handle_type) - && _CCCL_TRAIT(_CUDA_VSTD::is_default_constructible, mapping_type) - && _CCCL_TRAIT(_CUDA_VSTD::is_default_constructible, accessor_type)) + (extents_type::rank_dynamic() > 0) && _CCCL_TRAIT(is_default_constructible, data_handle_type) + && _CCCL_TRAIT(is_default_constructible, mapping_type) + && _CCCL_TRAIT(is_default_constructible, accessor_type)) = default; # endif __MDSPAN_INLINE_FUNCTION_DEFAULTED constexpr mdspan(const mdspan&) = default; __MDSPAN_INLINE_FUNCTION_DEFAULTED constexpr mdspan(mdspan&&) = default; - __MDSPAN_TEMPLATE_REQUIRES( - class... _SizeTypes, - /* requires */ ( - __MDSPAN_FOLD_AND(_CCCL_TRAIT(_CUDA_VSTD::is_convertible, _SizeTypes, index_type) /* && ... */) - && __MDSPAN_FOLD_AND(_CCCL_TRAIT(_CUDA_VSTD::is_nothrow_constructible, index_type, _SizeTypes) /* && ... */) - && ((sizeof...(_SizeTypes) == rank()) || (sizeof...(_SizeTypes) == rank_dynamic())) - && _CCCL_TRAIT(_CUDA_VSTD::is_constructible, mapping_type, extents_type) - && _CCCL_TRAIT(_CUDA_VSTD::is_default_constructible, accessor_type))) + _LIBCUDACXX_TEMPLATE(class... _SizeTypes) + _LIBCUDACXX_REQUIRES( + __MDSPAN_FOLD_AND(_CCCL_TRAIT(is_convertible, _SizeTypes, index_type) /* && ... */) + _LIBCUDACXX_AND __MDSPAN_FOLD_AND(_CCCL_TRAIT(is_nothrow_constructible, index_type, _SizeTypes) /* && ... */) + _LIBCUDACXX_AND((sizeof...(_SizeTypes) == rank()) || (sizeof...(_SizeTypes) == rank_dynamic())) + _LIBCUDACXX_AND _CCCL_TRAIT(is_constructible, mapping_type, extents_type) + _LIBCUDACXX_AND _CCCL_TRAIT(is_default_constructible, accessor_type)) __MDSPAN_INLINE_FUNCTION explicit constexpr mdspan(data_handle_type __p, _SizeTypes... __dynamic_extents) // TODO @proposal-bug shouldn't I be allowed to do `move(__p)` here? @@ -193,15 +192,11 @@ class mdspan accessor_type())) {} - __MDSPAN_TEMPLATE_REQUIRES( - class _SizeType, - size_t _Np, - /* requires */ - (_CCCL_TRAIT(_CUDA_VSTD::is_convertible, _SizeType, index_type) - && _CCCL_TRAIT(_CUDA_VSTD::is_nothrow_constructible, index_type, _SizeType) - && ((_Np == rank()) || (_Np == rank_dynamic())) - && _CCCL_TRAIT(_CUDA_VSTD::is_constructible, mapping_type, extents_type) - && _CCCL_TRAIT(_CUDA_VSTD::is_default_constructible, accessor_type))) + _LIBCUDACXX_TEMPLATE(class _SizeType, size_t _Np) + _LIBCUDACXX_REQUIRES(_CCCL_TRAIT(is_convertible, _SizeType, index_type) _LIBCUDACXX_AND _CCCL_TRAIT( + is_nothrow_constructible, index_type, _SizeType) _LIBCUDACXX_AND((_Np == rank()) || (_Np == rank_dynamic())) + _LIBCUDACXX_AND _CCCL_TRAIT(is_constructible, mapping_type, extents_type) + _LIBCUDACXX_AND _CCCL_TRAIT(is_default_constructible, accessor_type)) __MDSPAN_CONDITIONAL_EXPLICIT(_Np != rank_dynamic()) __MDSPAN_INLINE_FUNCTION constexpr mdspan(data_handle_type __p, const _CUDA_VSTD::array<_SizeType, _Np>& __dynamic_extents) @@ -209,15 +204,11 @@ class mdspan __map_acc_pair_t(mapping_type(extents_type(__dynamic_extents)), accessor_type())) {} - __MDSPAN_TEMPLATE_REQUIRES( - class _SizeType, - size_t _Np, - /* requires */ - (_CCCL_TRAIT(_CUDA_VSTD::is_convertible, _SizeType, index_type) - && _CCCL_TRAIT(_CUDA_VSTD::is_nothrow_constructible, index_type, _SizeType) - && ((_Np == rank()) || (_Np == rank_dynamic())) - && _CCCL_TRAIT(_CUDA_VSTD::is_constructible, mapping_type, extents_type) - && _CCCL_TRAIT(_CUDA_VSTD::is_default_constructible, accessor_type))) + _LIBCUDACXX_TEMPLATE(class _SizeType, size_t _Np) + _LIBCUDACXX_REQUIRES(_CCCL_TRAIT(is_convertible, _SizeType, index_type) _LIBCUDACXX_AND _CCCL_TRAIT( + is_nothrow_constructible, index_type, _SizeType) _LIBCUDACXX_AND((_Np == rank()) || (_Np == rank_dynamic())) + _LIBCUDACXX_AND _CCCL_TRAIT(is_constructible, mapping_type, extents_type) + _LIBCUDACXX_AND _CCCL_TRAIT(is_default_constructible, accessor_type)) __MDSPAN_CONDITIONAL_EXPLICIT(_Np != rank_dynamic()) __MDSPAN_INLINE_FUNCTION constexpr mdspan(data_handle_type __p, _CUDA_VSTD::span<_SizeType, _Np> __dynamic_extents) @@ -225,23 +216,16 @@ class mdspan __map_acc_pair_t(mapping_type(extents_type(_CUDA_VSTD::as_const(__dynamic_extents))), accessor_type())) {} - __MDSPAN_FUNCTION_REQUIRES( - (__MDSPAN_INLINE_FUNCTION constexpr), - mdspan, - (data_handle_type __p, const extents_type& __exts), - , - /* requires */ - (_CCCL_TRAIT(_CUDA_VSTD::is_default_constructible, accessor_type) - && _CCCL_TRAIT(_CUDA_VSTD::is_constructible, mapping_type, extents_type))) + _LIBCUDACXX_TEMPLATE(bool _Is_default_constructible = _CCCL_TRAIT(is_default_constructible, accessor_type)) + _LIBCUDACXX_REQUIRES( + _Is_default_constructible _LIBCUDACXX_AND _CCCL_TRAIT(is_constructible, mapping_type, extents_type)) + __MDSPAN_INLINE_FUNCTION constexpr mdspan(data_handle_type __p, const extents_type& __exts) : __members(_CUDA_VSTD::move(__p), __map_acc_pair_t(mapping_type(__exts), accessor_type())) {} - __MDSPAN_FUNCTION_REQUIRES( - (__MDSPAN_INLINE_FUNCTION constexpr), - mdspan, - (data_handle_type __p, const mapping_type& __m), - , - /* requires */ (_CCCL_TRAIT(_CUDA_VSTD::is_default_constructible, accessor_type))) + _LIBCUDACXX_TEMPLATE(bool _Is_default_constructible = _CCCL_TRAIT(is_default_constructible, accessor_type)) + _LIBCUDACXX_REQUIRES(_Is_default_constructible) + __MDSPAN_INLINE_FUNCTION constexpr mdspan(data_handle_type __p, const mapping_type& __m) : __members(_CUDA_VSTD::move(__p), __map_acc_pair_t(__m, accessor_type())) {} @@ -250,23 +234,17 @@ class mdspan : __members(_CUDA_VSTD::move(__p), __map_acc_pair_t(__m, __a)) {} - __MDSPAN_TEMPLATE_REQUIRES( - class _OtherElementType, - class _OtherExtents, - class _OtherLayoutPolicy, - class _OtherAccessor, - /* requires */ - (_CCCL_TRAIT( - _CUDA_VSTD::is_constructible, mapping_type, typename _OtherLayoutPolicy::template mapping<_OtherExtents>) - && _CCCL_TRAIT(_CUDA_VSTD::is_constructible, accessor_type, _OtherAccessor))) + _LIBCUDACXX_TEMPLATE(class _OtherElementType, class _OtherExtents, class _OtherLayoutPolicy, class _OtherAccessor) + _LIBCUDACXX_REQUIRES( + _CCCL_TRAIT(is_constructible, mapping_type, typename _OtherLayoutPolicy::template mapping<_OtherExtents>) + _LIBCUDACXX_AND _CCCL_TRAIT(is_constructible, accessor_type, _OtherAccessor)) __MDSPAN_INLINE_FUNCTION constexpr mdspan(const mdspan<_OtherElementType, _OtherExtents, _OtherLayoutPolicy, _OtherAccessor>& __other) : __members(__other.__ptr_ref(), __map_acc_pair_t(__other.__mapping_ref(), __other.__accessor_ref())) { - static_assert( - _CCCL_TRAIT(_CUDA_VSTD::is_constructible, data_handle_type, typename _OtherAccessor::data_handle_type), - "Incompatible data_handle_type for mdspan construction"); - static_assert(_CCCL_TRAIT(_CUDA_VSTD::is_constructible, extents_type, _OtherExtents), + static_assert(_CCCL_TRAIT(is_constructible, data_handle_type, typename _OtherAccessor::data_handle_type), + "Incompatible data_handle_type for mdspan construction"); + static_assert(_CCCL_TRAIT(is_constructible, extents_type, _OtherExtents), "Incompatible extents for mdspan construction"); /* * TODO: Check precondition @@ -287,12 +265,11 @@ class mdspan // [mdspan.basic.mapping], mdspan mapping domain multidimensional index to access codomain element # if __MDSPAN_USE_BRACKET_OPERATOR - __MDSPAN_TEMPLATE_REQUIRES( - class... _SizeTypes, - /* requires */ ( - __MDSPAN_FOLD_AND(_CCCL_TRAIT(_CUDA_VSTD::is_convertible, _SizeTypes, index_type) /* && ... */) - && __MDSPAN_FOLD_AND(_CCCL_TRAIT(_CUDA_VSTD::is_nothrow_constructible, index_type, _SizeTypes) /* && ... */) - && (rank() == sizeof...(_SizeTypes)))) + _LIBCUDACXX_TEMPLATE(class... _SizeTypes) + _LIBCUDACXX_REQUIRES( + __MDSPAN_FOLD_AND(_CCCL_TRAIT(is_convertible, _SizeTypes, index_type) /* && ... */) + _LIBCUDACXX_AND __MDSPAN_FOLD_AND(_CCCL_TRAIT(is_nothrow_constructible, index_type, _SizeTypes) /* && ... */) + _LIBCUDACXX_AND(rank() == sizeof...(_SizeTypes))) __MDSPAN_FORCE_INLINE_FUNCTION constexpr reference operator[](_SizeTypes... __indices) const { @@ -300,20 +277,18 @@ class mdspan } # endif - __MDSPAN_TEMPLATE_REQUIRES( - class _SizeType, - /* requires */ (_CCCL_TRAIT(_CUDA_VSTD::is_convertible, _SizeType, index_type) - && _CCCL_TRAIT(_CUDA_VSTD::is_nothrow_constructible, index_type, _SizeType))) + _LIBCUDACXX_TEMPLATE(class _SizeType) + _LIBCUDACXX_REQUIRES(_CCCL_TRAIT(is_convertible, _SizeType, index_type) + _LIBCUDACXX_AND _CCCL_TRAIT(is_nothrow_constructible, index_type, _SizeType)) __MDSPAN_FORCE_INLINE_FUNCTION constexpr reference operator[](const _CUDA_VSTD::array<_SizeType, rank()>& __indices) const { return __impl::template __callop(*this, __indices); } - __MDSPAN_TEMPLATE_REQUIRES( - class _SizeType, - /* requires */ (_CCCL_TRAIT(_CUDA_VSTD::is_convertible, _SizeType, index_type) - && _CCCL_TRAIT(_CUDA_VSTD::is_nothrow_constructible, index_type, _SizeType))) + _LIBCUDACXX_TEMPLATE(class _SizeType) + _LIBCUDACXX_REQUIRES(_CCCL_TRAIT(is_convertible, _SizeType, index_type) + _LIBCUDACXX_AND _CCCL_TRAIT(is_nothrow_constructible, index_type, _SizeType)) __MDSPAN_FORCE_INLINE_FUNCTION constexpr reference operator[](_CUDA_VSTD::span<_SizeType, rank()> __indices) const { @@ -321,10 +296,9 @@ class mdspan } # if !__MDSPAN_USE_BRACKET_OPERATOR - __MDSPAN_TEMPLATE_REQUIRES(class _Index, - /* requires */ (_CCCL_TRAIT(_CUDA_VSTD::is_convertible, _Index, index_type) - && _CCCL_TRAIT(_CUDA_VSTD::is_nothrow_constructible, index_type, _Index) - && extents_type::rank() == 1)) + _LIBCUDACXX_TEMPLATE(class _Index) + _LIBCUDACXX_REQUIRES(_CCCL_TRAIT(is_convertible, _Index, index_type) _LIBCUDACXX_AND _CCCL_TRAIT( + is_nothrow_constructible, index_type, _Index) _LIBCUDACXX_AND(extents_type::rank() == 1)) __MDSPAN_FORCE_INLINE_FUNCTION constexpr reference operator[](_Index __idx) const { @@ -333,32 +307,29 @@ class mdspan # endif # if __MDSPAN_USE_PAREN_OPERATOR - __MDSPAN_TEMPLATE_REQUIRES( - class... _SizeTypes, - /* requires */ ( - __MDSPAN_FOLD_AND(_CCCL_TRAIT(_CUDA_VSTD::is_convertible, _SizeTypes, index_type) /* && ... */) - && __MDSPAN_FOLD_AND(_CCCL_TRAIT(_CUDA_VSTD::is_nothrow_constructible, index_type, _SizeTypes) /* && ... */) - && extents_type::rank() == sizeof...(_SizeTypes))) + _LIBCUDACXX_TEMPLATE(class... _SizeTypes) + _LIBCUDACXX_REQUIRES( + __MDSPAN_FOLD_AND(_CCCL_TRAIT(is_convertible, _SizeTypes, index_type) /* && ... */) + _LIBCUDACXX_AND __MDSPAN_FOLD_AND(_CCCL_TRAIT(is_nothrow_constructible, index_type, _SizeTypes) /* && ... */) + _LIBCUDACXX_AND(extents_type::rank() == sizeof...(_SizeTypes))) __MDSPAN_FORCE_INLINE_FUNCTION constexpr reference operator()(_SizeTypes... __indices) const { return __accessor_ref().access(__ptr_ref(), __mapping_ref()(__indices...)); } - __MDSPAN_TEMPLATE_REQUIRES( - class _SizeType, - /* requires */ (_CCCL_TRAIT(_CUDA_VSTD::is_convertible, _SizeType, index_type) - && _CCCL_TRAIT(_CUDA_VSTD::is_nothrow_constructible, index_type, _SizeType))) + _LIBCUDACXX_TEMPLATE(class _SizeType) + _LIBCUDACXX_REQUIRES(_CCCL_TRAIT(is_convertible, _SizeType, index_type) + _LIBCUDACXX_AND _CCCL_TRAIT(is_nothrow_constructible, index_type, _SizeType)) __MDSPAN_FORCE_INLINE_FUNCTION constexpr reference operator()(const _CUDA_VSTD::array<_SizeType, rank()>& __indices) const { return __impl::template __callop(*this, __indices); } - __MDSPAN_TEMPLATE_REQUIRES( - class _SizeType, - /* requires */ (_CCCL_TRAIT(_CUDA_VSTD::is_convertible, _SizeType, index_type) - && _CCCL_TRAIT(_CUDA_VSTD::is_nothrow_constructible, index_type, _SizeType))) + _LIBCUDACXX_TEMPLATE(class _SizeType) + _LIBCUDACXX_REQUIRES(_CCCL_TRAIT(is_convertible, _SizeType, index_type) + _LIBCUDACXX_AND _CCCL_TRAIT(is_nothrow_constructible, index_type, _SizeType)) __MDSPAN_FORCE_INLINE_FUNCTION constexpr reference operator()(_CUDA_VSTD::span<_SizeType, rank()> __indices) const { @@ -470,17 +441,18 @@ class mdspan }; # if defined(__MDSPAN_USE_CLASS_TEMPLATE_ARGUMENT_DEDUCTION) -__MDSPAN_TEMPLATE_REQUIRES( - class _ElementType, - class... _SizeTypes, - /* requires */ __MDSPAN_FOLD_AND(_CCCL_TRAIT(is_integral, _SizeTypes) /* && ... */) && (sizeof...(_SizeTypes) > 0)) +_LIBCUDACXX_TEMPLATE(class _ElementType, class... _SizeTypes) +_LIBCUDACXX_REQUIRES(__MDSPAN_FOLD_AND(_CCCL_TRAIT(is_integral, _SizeTypes) /* && ... */) + _LIBCUDACXX_AND(sizeof...(_SizeTypes) > 0)) _CCCL_HOST_DEVICE explicit mdspan(_ElementType*, _SizeTypes...) -> mdspan<_ElementType, dextents>; -__MDSPAN_TEMPLATE_REQUIRES(class _Pointer, (_CCCL_TRAIT(is_pointer, _CUDA_VSTD::remove_reference_t<_Pointer>))) +_LIBCUDACXX_TEMPLATE(class _Pointer) +_LIBCUDACXX_REQUIRES(_CCCL_TRAIT(is_pointer, _CUDA_VSTD::remove_reference_t<_Pointer>)) _CCCL_HOST_DEVICE mdspan(_Pointer&&) -> mdspan<_CUDA_VSTD::remove_pointer_t<_CUDA_VSTD::remove_reference_t<_Pointer>>, extents>; -__MDSPAN_TEMPLATE_REQUIRES(class _CArray, (_CCCL_TRAIT(is_array, _CArray) && (rank_v<_CArray> == 1))) +_LIBCUDACXX_TEMPLATE(class _CArray) +_LIBCUDACXX_REQUIRES(_CCCL_TRAIT(is_array, _CArray) _LIBCUDACXX_AND(rank_v<_CArray> == 1)) _CCCL_HOST_DEVICE mdspan(_CArray&) -> mdspan<_CUDA_VSTD::remove_all_extents_t<_CArray>, extents>>; diff --git a/libcudacxx/include/cuda/std/__mdspan/static_array.h b/libcudacxx/include/cuda/std/__mdspan/static_array.h index de511fe2e6..886f782065 100644 --- a/libcudacxx/include/cuda/std/__mdspan/static_array.h +++ b/libcudacxx/include/cuda/std/__mdspan/static_array.h @@ -162,21 +162,17 @@ class __partially_static_array_impl< {} __MDSPAN_INLINE_FUNCTION constexpr explicit __partially_static_array_impl( - _CUDA_VSTD::array<_Tp, sizeof...(_Idxs)> const& __vals) noexcept + array<_Tp, sizeof...(_Idxs)> const& __vals) noexcept : __partially_static_array_impl(__construct_psa_from_all_exts_values_tag, _CUDA_VSTD::get<_Idxs>(__vals)...) {} - // clang-format off - __MDSPAN_FUNCTION_REQUIRES( - (__MDSPAN_INLINE_FUNCTION constexpr explicit), - __partially_static_array_impl, - (_CUDA_VSTD::array<_Tp, __size_dynamic> const &__vals), noexcept, - /* requires */ - (sizeof...(_Idxs) != __size_dynamic) - ): __partially_static_array_impl( - __construct_psa_from_dynamic_exts_values_tag, - _CUDA_VSTD::get<_IdxsDynamicIdxs>(__vals)...) {} - // clang-format on + _LIBCUDACXX_TEMPLATE(bool _SizeMatches = (sizeof...(_Idxs) != __size_dynamic)) + _LIBCUDACXX_REQUIRES(_SizeMatches) + __MDSPAN_INLINE_FUNCTION constexpr explicit __partially_static_array_impl( + array<_Tp, __size_dynamic> const& __vals) noexcept + __partially_static_array_impl(__construct_psa_from_dynamic_exts_values_tag, + _CUDA_VSTD::get<_IdxsDynamicIdxs>(__vals)...) + {} template : true_type //============================================================================== -__MDSPAN_TEMPLATE_REQUIRES( - class _ET, - class _EXT, - class _LP, - class _AP, - class... _SliceSpecs, - /* requires */ - ((_CCCL_TRAIT(_CUDA_VSTD::is_same, _LP, layout_left) || _CCCL_TRAIT(_CUDA_VSTD::is_same, _LP, layout_right) - || __detail::_is_layout_stride<_LP>::value) - && __MDSPAN_FOLD_AND((_CCCL_TRAIT(_CUDA_VSTD::is_convertible, _SliceSpecs, size_t) - || _CCCL_TRAIT(_CUDA_VSTD::is_convertible, _SliceSpecs, tuple) - || _CCCL_TRAIT(_CUDA_VSTD::is_convertible, _SliceSpecs, full_extent_t)) /* && ... */) - && sizeof...(_SliceSpecs) == _EXT::rank())) +_LIBCUDACXX_TEMPLATE(class _ET, class _EXT, class _LP, class _AP, class... _SliceSpecs) +_LIBCUDACXX_REQUIRES( + (_CCCL_TRAIT(_CUDA_VSTD::is_same, _LP, layout_left) || _CCCL_TRAIT(_CUDA_VSTD::is_same, _LP, layout_right) + || __detail::_is_layout_stride<_LP>::value) + _LIBCUDACXX_AND __MDSPAN_FOLD_AND( + (_CCCL_TRAIT(_CUDA_VSTD::is_convertible, _SliceSpecs, size_t) + || _CCCL_TRAIT(_CUDA_VSTD::is_convertible, _SliceSpecs, tuple) + || _CCCL_TRAIT(_CUDA_VSTD::is_convertible, _SliceSpecs, full_extent_t)) /* && ... */) + _LIBCUDACXX_AND(sizeof...(_SliceSpecs) == _EXT::rank())) __MDSPAN_INLINE_FUNCTION __MDSPAN_DEDUCE_RETURN_TYPE_SINGLE_LINE( (constexpr submdspan(mdspan<_ET, _EXT, _LP, _AP> const& __src, _SliceSpecs... __slices) noexcept), diff --git a/libcudacxx/test/libcudacxx/std/containers/views/mdspan/foo_customizations.hpp b/libcudacxx/test/libcudacxx/std/containers/views/mdspan/foo_customizations.hpp index 32e7c1cd84..fd84ddcc51 100644 --- a/libcudacxx/test/libcudacxx/std/containers/views/mdspan/foo_customizations.hpp +++ b/libcudacxx/test/libcudacxx/std/containers/views/mdspan/foo_customizations.hpp @@ -93,8 +93,8 @@ class layout_foo::mapping : __extents(__exts) {} - __MDSPAN_TEMPLATE_REQUIRES(class OtherExtents, - /* requires */ (_CCCL_TRAIT(cuda::std::is_constructible, extents_type, OtherExtents))) + _LIBCUDACXX_TEMPLATE(class OtherExtents) + _LIBCUDACXX_REQUIRES(_CCCL_TRAIT(cuda::std::is_constructible, extents_type, OtherExtents)) __MDSPAN_CONDITIONAL_EXPLICIT((!cuda::std::is_convertible::value)) // needs two () due to // comma __MDSPAN_INLINE_FUNCTION constexpr mapping( @@ -107,18 +107,18 @@ class layout_foo::mapping */ } - __MDSPAN_TEMPLATE_REQUIRES(class OtherExtents, - /* requires */ (_CCCL_TRAIT(cuda::std::is_constructible, extents_type, OtherExtents))) - __MDSPAN_CONDITIONAL_EXPLICIT((!cuda::std::is_convertible::value)) // needs two () due to - // comma + _LIBCUDACXX_TEMPLATE(class OtherExtents) + _LIBCUDACXX_REQUIRES(_CCCL_TRAIT(cuda::std::is_constructible, extents_type, OtherExtents)) + __MDSPAN_CONDITIONAL_EXPLICIT((!cuda::std::is_convertible::value)) // needs two () due + // to comma __MDSPAN_INLINE_FUNCTION constexpr mapping( cuda::std::layout_right::mapping const& other) noexcept // NOLINT(google-explicit-constructor) : __extents(other.extents()) {} - __MDSPAN_TEMPLATE_REQUIRES(class OtherExtents, - /* requires */ (_CCCL_TRAIT(cuda::std::is_constructible, extents_type, OtherExtents) - && (extents_type::rank() <= 1))) + _LIBCUDACXX_TEMPLATE(class OtherExtents) + _LIBCUDACXX_REQUIRES(_CCCL_TRAIT(cuda::std::is_constructible, extents_type, OtherExtents) + && (extents_type::rank() <= 1)) __MDSPAN_CONDITIONAL_EXPLICIT((!cuda::std::is_convertible::value)) // needs two () due to // comma __MDSPAN_INLINE_FUNCTION constexpr mapping( @@ -126,8 +126,8 @@ class layout_foo::mapping : __extents(other.extents()) {} - __MDSPAN_TEMPLATE_REQUIRES(class OtherExtents, - /* requires */ (_CCCL_TRAIT(cuda::std::is_constructible, extents_type, OtherExtents))) + _LIBCUDACXX_TEMPLATE(class OtherExtents) + _LIBCUDACXX_REQUIRES(_CCCL_TRAIT(cuda::std::is_constructible, extents_type, OtherExtents)) __MDSPAN_CONDITIONAL_EXPLICIT((extents_type::rank() > 0)) __MDSPAN_INLINE_FUNCTION constexpr mapping( cuda::std::layout_stride::mapping const& other) // NOLINT(google-explicit-constructor)