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

Make MSVC+NVCC working #307

Merged
merged 1 commit into from
Jan 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 21 additions & 10 deletions include/experimental/__p0009_bits/extents.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,14 @@ __check_compatible_extents(
return {};
}

template<class IndexType, class ... Arguments>
MDSPAN_INLINE_FUNCTION
static constexpr bool are_valid_indices() {
return
(std::is_convertible_v<Arguments, IndexType> && ... && true) &&
(std::is_nothrow_constructible_v<IndexType, Arguments> && ... && true);
}

// ------------------------------------------------------------------
// ------------ static_array ----------------------------------------
// ------------------------------------------------------------------
Expand Down Expand Up @@ -499,17 +507,20 @@ template <class IndexType, size_t... Extents> class extents {
public:

// Converting constructor from other extents specializations
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(
std::integral_constant<bool, sizeof...(Extents) ==
sizeof...(OtherExtents)>{},
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(
// using: sizeof...(Extents) == sizeof...(OtherExtents) as the second argument fails with MSVC+NVCC with some obscure expansion error
// MSVC: 19.38.33133 NVCC: 12.0
std::integral_constant<bool, extents<int, Extents...>::rank() == extents<int, OtherExtents...>::rank()>{},
std::integer_sequence<size_t, Extents...>{},
std::integer_sequence<size_t, OtherExtents...>{}))::value))
std::integer_sequence<size_t, OtherExtents...>{}))::value
)
)
MDSPAN_INLINE_FUNCTION
MDSPAN_CONDITIONAL_EXPLICIT((((Extents != dynamic_extent) &&
(OtherExtents == dynamic_extent)) ||
Expand Down
5 changes: 1 addition & 4 deletions include/experimental/__p0009_bits/layout_left.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -189,10 +189,7 @@ class layout_left::mapping {
class... Indices,
/* requires */ (
(sizeof...(Indices) == extents_type::rank()) &&
_MDSPAN_FOLD_AND(
(_MDSPAN_TRAIT(std::is_convertible, Indices, index_type) &&
_MDSPAN_TRAIT(std::is_nothrow_constructible, index_type, Indices))
)
(detail::are_valid_indices<index_type, Indices...>())
)
)
_MDSPAN_HOST_DEVICE
Expand Down
9 changes: 3 additions & 6 deletions include/experimental/__p0009_bits/layout_right.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -188,13 +188,10 @@ class layout_right::mapping {
//--------------------------------------------------------------------------------

MDSPAN_TEMPLATE_REQUIRES(
class... Indices,
class ... Indices,
/* requires */ (
(sizeof...(Indices) == extents_type::rank()) &&
_MDSPAN_FOLD_AND(
(_MDSPAN_TRAIT(std::is_convertible, Indices, index_type) &&
_MDSPAN_TRAIT(std::is_nothrow_constructible, index_type, Indices))
)
(sizeof...(Indices) == extents_type::rank()) &&
(detail::are_valid_indices<index_type, Indices...>())
)
)
_MDSPAN_HOST_DEVICE
Expand Down
3 changes: 1 addition & 2 deletions include/experimental/__p0009_bits/layout_stride.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -424,8 +424,7 @@ struct layout_stride {
class... Indices,
/* requires */ (
sizeof...(Indices) == Extents::rank() &&
_MDSPAN_FOLD_AND(_MDSPAN_TRAIT(std::is_convertible, Indices, index_type) /*&& ...*/ ) &&
_MDSPAN_FOLD_AND(_MDSPAN_TRAIT(std::is_nothrow_constructible, index_type, Indices) /*&& ...*/)
(detail::are_valid_indices<index_type, Indices...>())
)
)
MDSPAN_FORCE_INLINE_FUNCTION
Expand Down
8 changes: 3 additions & 5 deletions include/experimental/__p0009_bits/mdspan.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,8 @@ class mdspan
MDSPAN_TEMPLATE_REQUIRES(
class... SizeTypes,
/* requires */ (
_MDSPAN_FOLD_AND(_MDSPAN_TRAIT(std::is_convertible, SizeTypes, index_type) /* && ... */) &&
_MDSPAN_FOLD_AND(_MDSPAN_TRAIT(std::is_nothrow_constructible, index_type, SizeTypes) /* && ... */) &&
((sizeof...(SizeTypes) == rank()) || (sizeof...(SizeTypes) == rank_dynamic())) &&
(detail::are_valid_indices<index_type, SizeTypes...>()) &&
_MDSPAN_TRAIT(std::is_constructible, mapping_type, extents_type) &&
_MDSPAN_TRAIT(std::is_default_constructible, accessor_type)
)
Expand Down Expand Up @@ -282,9 +281,8 @@ class mdspan
MDSPAN_TEMPLATE_REQUIRES(
class... SizeTypes,
/* requires */ (
_MDSPAN_FOLD_AND(_MDSPAN_TRAIT(std::is_convertible, SizeTypes, index_type) /* && ... */) &&
_MDSPAN_FOLD_AND(_MDSPAN_TRAIT(std::is_nothrow_constructible, index_type, SizeTypes) /* && ... */) &&
extents_type::rank() == sizeof...(SizeTypes)
extents_type::rank() == sizeof...(SizeTypes) &&
(detail::are_valid_indices<index_type, SizeTypes...>())
)
)
MDSPAN_FORCE_INLINE_FUNCTION
Expand Down
12 changes: 6 additions & 6 deletions include/experimental/__p1684_bits/mdarray.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,8 @@ class mdarray {
MDSPAN_TEMPLATE_REQUIRES(
class... SizeTypes,
/* requires */ (
_MDSPAN_FOLD_AND(_MDSPAN_TRAIT( std::is_convertible, SizeTypes, index_type) /* && ... */) &&
_MDSPAN_TRAIT( std::is_constructible, extents_type, SizeTypes...) &&
(::MDSPAN_IMPL_STANDARD_NAMESPACE::detail::are_valid_indices<index_type, SizeTypes...>()) &&
_MDSPAN_TRAIT( std::is_constructible, extents_type, SizeTypes...) &&
_MDSPAN_TRAIT( std::is_constructible, mapping_type, extents_type) &&
(_MDSPAN_TRAIT( std::is_constructible, container_type, size_t) ||
container_is_array<container_type>::value) &&
Expand Down Expand Up @@ -312,8 +312,8 @@ class mdarray {
MDSPAN_TEMPLATE_REQUIRES(
class... SizeTypes,
/* requires */ (
_MDSPAN_FOLD_AND(_MDSPAN_TRAIT( std::is_convertible, SizeTypes, index_type) /* && ... */) &&
extents_type::rank() == sizeof...(SizeTypes)
(::MDSPAN_IMPL_STANDARD_NAMESPACE::detail::are_valid_indices<index_type, SizeTypes...>()) &&
extents_type::rank() == sizeof...(SizeTypes)
)
)
MDSPAN_FORCE_INLINE_FUNCTION
Expand All @@ -324,8 +324,8 @@ class mdarray {
MDSPAN_TEMPLATE_REQUIRES(
class... SizeTypes,
/* requires */ (
_MDSPAN_FOLD_AND(_MDSPAN_TRAIT( std::is_convertible, SizeTypes, index_type) /* && ... */) &&
extents_type::rank() == sizeof...(SizeTypes)
(::MDSPAN_IMPL_STANDARD_NAMESPACE::detail::are_valid_indices<index_type, SizeTypes...>()) &&
extents_type::rank() == sizeof...(SizeTypes)
)
)
MDSPAN_FORCE_INLINE_FUNCTION
Expand Down
14 changes: 6 additions & 8 deletions include/experimental/__p2642_bits/layout_padded.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -374,11 +374,10 @@ class layout_left_padded<PaddingValue>::mapping {
* - (is_nothrow_constructible_v<index_type, Indices> && ...) is true.
*/
MDSPAN_TEMPLATE_REQUIRES(
class... _Indices,
/* requires */ (
sizeof...(_Indices) == extents_type::rank()
&& (std::is_convertible_v<_Indices, index_type> && ...)
&& (std::is_nothrow_constructible_v<index_type, _Indices> && ...)
class... _Indices,
/* requires */ (
sizeof...(_Indices) == extents_type::rank() &&
(::MDSPAN_IMPL_STANDARD_NAMESPACE::detail::are_valid_indices<index_type, _Indices...>())
)
)
constexpr size_t operator()(_Indices... idxs) const noexcept
Expand Down Expand Up @@ -707,9 +706,8 @@ class layout_right_padded<PaddingValue>::mapping {
MDSPAN_TEMPLATE_REQUIRES(
class... _Indices,
/* requires */ (
sizeof...(_Indices) == extents_type::rank()
&& (std::is_convertible_v<_Indices, index_type> && ...)
&& (std::is_nothrow_constructible_v<index_type, _Indices> && ...)
sizeof...(_Indices) == extents_type::rank() &&
(::MDSPAN_IMPL_STANDARD_NAMESPACE::detail::are_valid_indices<index_type, _Indices...>())
)
)
constexpr size_t operator()(_Indices... idxs) const noexcept
Expand Down
Loading