Skip to content

Commit

Permalink
add p264r2->r3 changes to return type of extents() function
Browse files Browse the repository at this point in the history
  • Loading branch information
nmm0 committed Aug 1, 2023
1 parent ff3a911 commit d0bcf74
Showing 1 changed file with 30 additions and 26 deletions.
56 changes: 30 additions & 26 deletions include/experimental/__p2642_bits/layout_padded.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,7 @@ class layout_left_padded<padding_stride>::mapping {

__inner_mapping_type __inner_mapping;
__unpadded_extent_type __unpadded_extent;
extents_type __actual_extents = {};

public:
#if !MDSPAN_HAS_CXX_20
Expand Down Expand Up @@ -245,7 +246,8 @@ class layout_left_padded<padding_stride>::mapping {
MDSPAN_INLINE_FUNCTION
constexpr mapping(const extents_type& __ext)
: __inner_mapping(detail::__inner_extents_type<__extent_to_pad_idx, extents_type, __actual_padding_stride>::template __construct<padding_stride>(__ext)),
__unpadded_extent(detail::__construct_unpadded_extent_type(__ext, std::integral_constant<rank_type, __extent_to_pad_idx>{}))
__unpadded_extent(detail::__construct_unpadded_extent_type(__ext, std::integral_constant<rank_type, __extent_to_pad_idx>{})),
__actual_extents(__ext)
{}

/**
Expand All @@ -267,7 +269,8 @@ class layout_left_padded<padding_stride>::mapping {
MDSPAN_INLINE_FUNCTION
constexpr mapping(const extents_type &__ext, _Size __padding_value)
: __inner_mapping(detail::__inner_extents_type<__extent_to_pad_idx, extents_type, __actual_padding_stride>::template __construct<padding_stride>(__ext, static_cast<index_type>(__padding_value))),
__unpadded_extent(detail::__construct_unpadded_extent_type(__ext, std::integral_constant<rank_type, __extent_to_pad_idx>{}))
__unpadded_extent(detail::__construct_unpadded_extent_type(__ext, std::integral_constant<rank_type, __extent_to_pad_idx>{})),
__actual_extents(__ext)
{
assert((padding_stride == dynamic_extent) || (padding_stride == static_cast<index_type>(__padding_value)));
}
Expand All @@ -288,7 +291,8 @@ class layout_left_padded<padding_stride>::mapping {
MDSPAN_CONDITIONAL_EXPLICIT((!std::is_convertible_v<_OtherExtents, extents_type>))
constexpr mapping(const layout_left::mapping<_OtherExtents> &__other_mapping)
: __inner_mapping(detail::__inner_extents_type<__extent_to_pad_idx, extents_type, __actual_padding_stride>::template __construct_other<padding_stride>(__other_mapping.extents(), __padding_stride_idx, __other_mapping)),
__unpadded_extent(detail::__construct_unpadded_extent_type(__other_mapping.extents(), std::integral_constant<rank_type, __extent_to_pad_idx>{}))
__unpadded_extent(detail::__construct_unpadded_extent_type(__other_mapping.extents(), std::integral_constant<rank_type, __extent_to_pad_idx>{})),
__actual_extents(__other_mapping.extents())
{
static_assert(!((_OtherExtents::rank() > 1) && (__actual_padding_stride != dynamic_extent) && (_OtherExtents::static_extent(__extent_to_pad_idx) != dynamic_extent))
|| (__actual_padding_stride == _OtherExtents::static_extent(__extent_to_pad_idx)));
Expand All @@ -308,7 +312,8 @@ class layout_left_padded<padding_stride>::mapping {
MDSPAN_CONDITIONAL_EXPLICIT((extents_type::rank() > 0))
constexpr mapping(const layout_stride::mapping<_OtherExtents> &__other_mapping)
: __inner_mapping(detail::__inner_extents_type<__extent_to_pad_idx, extents_type, __actual_padding_stride>::template __construct_other<padding_stride>(__other_mapping.extents(), __padding_stride_idx, __other_mapping)),
__unpadded_extent(detail::__construct_unpadded_extent_type(__other_mapping.extents(), std::integral_constant<rank_type, __extent_to_pad_idx>{}))
__unpadded_extent(detail::__construct_unpadded_extent_type(__other_mapping.extents(), std::integral_constant<rank_type, __extent_to_pad_idx>{})),
__actual_extents(__other_mapping.extents())
{
}

Expand All @@ -329,7 +334,8 @@ class layout_left_padded<padding_stride>::mapping {
constexpr
mapping(const _Mapping &__other_mapping)
: __inner_mapping(detail::__inner_extents_type<__extent_to_pad_idx, extents_type, __actual_padding_stride>::template __construct_other<padding_stride>(__other_mapping.extents(), __padding_stride_idx, __other_mapping)),
__unpadded_extent(detail::__construct_unpadded_extent_type(__other_mapping.extents(), std::integral_constant<rank_type, __extent_to_pad_idx>{}))
__unpadded_extent(detail::__construct_unpadded_extent_type(__other_mapping.extents(), std::integral_constant<rank_type, __extent_to_pad_idx>{})),
__actual_extents(__other_mapping.extents())
{
static_assert(padding_stride == dynamic_extent
|| detail::__padded_layout_padding_stride<typename _Mapping::layout_type>::value == dynamic_extent
Expand All @@ -353,17 +359,13 @@ class layout_left_padded<padding_stride>::mapping {
constexpr
mapping(const _Mapping &__other_mapping) noexcept
: __inner_mapping(__other_mapping.extents()),
__unpadded_extent(detail::__construct_unpadded_extent_type(__other_mapping.extents(), std::integral_constant<rank_type, __extent_to_pad_idx>{}))
__unpadded_extent(detail::__construct_unpadded_extent_type(__other_mapping.extents(), std::integral_constant<rank_type, __extent_to_pad_idx>{})),
__actual_extents(__other_mapping.extents())
{}

constexpr extents_type extents() const noexcept
constexpr const extents_type &extents() const noexcept
{
if constexpr (extents_type::rank() == size_t(0))
{
return {};
} else {
return detail::__substitute_extents<__extent_to_pad_idx, __inner_extents_type, __unpadded_extent_type::static_extent(0)>::template __construct_with_type<extents_type>(__inner_mapping.extents(), __unpadded_extent);
}
return __actual_extents;
}

constexpr std::array<index_type, extents_type::rank()>
Expand Down Expand Up @@ -509,6 +511,7 @@ class layout_right_padded<padding_stride>::mapping {

__inner_mapping_type __inner_mapping;
__unpadded_extent_type __unpadded_extent;
extents_type __actual_extents = {};

public:
#if !MDSPAN_HAS_CXX_20
Expand Down Expand Up @@ -539,7 +542,8 @@ class layout_right_padded<padding_stride>::mapping {
MDSPAN_INLINE_FUNCTION
constexpr mapping(const extents_type &__ext)
: __inner_mapping(detail::__inner_extents_type<__extent_to_pad_idx, extents_type, __actual_padding_stride>::template __construct<padding_stride>(__ext)),
__unpadded_extent(detail::__construct_unpadded_extent_type(__ext, std::integral_constant<rank_type, __extent_to_pad_idx>{}))
__unpadded_extent(detail::__construct_unpadded_extent_type(__ext, std::integral_constant<rank_type, __extent_to_pad_idx>{})),
__actual_extents(__ext)
{}

/**
Expand All @@ -561,7 +565,8 @@ class layout_right_padded<padding_stride>::mapping {
MDSPAN_INLINE_FUNCTION
constexpr mapping(const extents_type &__ext, _Size __padding_value)
: __inner_mapping(detail::__inner_extents_type<__extent_to_pad_idx, extents_type, __actual_padding_stride>::template __construct<padding_stride>(__ext, static_cast<index_type>(__padding_value))),
__unpadded_extent(detail::__construct_unpadded_extent_type(__ext, std::integral_constant<rank_type, __extent_to_pad_idx>{}))
__unpadded_extent(detail::__construct_unpadded_extent_type(__ext, std::integral_constant<rank_type, __extent_to_pad_idx>{})),
__actual_extents(__ext)
{
assert((padding_stride == dynamic_extent) || (padding_stride == static_cast<index_type>(__padding_value)));
}
Expand All @@ -582,7 +587,8 @@ class layout_right_padded<padding_stride>::mapping {
MDSPAN_CONDITIONAL_EXPLICIT((!std::is_convertible_v<_OtherExtents, extents_type>))
constexpr mapping(const layout_right::mapping<_OtherExtents> &__other_mapping)
: __inner_mapping(detail::__inner_extents_type<__extent_to_pad_idx, extents_type, __actual_padding_stride>::template __construct_other<padding_stride>(__other_mapping.extents(), __padding_stride_idx, __other_mapping)),
__unpadded_extent(detail::__construct_unpadded_extent_type(__other_mapping.extents(), std::integral_constant<rank_type, __extent_to_pad_idx>{}))
__unpadded_extent(detail::__construct_unpadded_extent_type(__other_mapping.extents(), std::integral_constant<rank_type, __extent_to_pad_idx>{})),
__actual_extents(__other_mapping.extents())
{
static_assert(!((_OtherExtents::rank() > 1) && (__actual_padding_stride != dynamic_extent) && (_OtherExtents::static_extent(__extent_to_pad_idx) != dynamic_extent))
|| (__actual_padding_stride == _OtherExtents::static_extent(__extent_to_pad_idx)));
Expand All @@ -602,7 +608,8 @@ class layout_right_padded<padding_stride>::mapping {
MDSPAN_CONDITIONAL_EXPLICIT((extents_type::rank() > 0))
constexpr mapping(const layout_stride::mapping<_OtherExtents> &__other_mapping)
: __inner_mapping(detail::__inner_extents_type<__extent_to_pad_idx, extents_type, __actual_padding_stride>::template __construct_other<padding_stride>(__other_mapping.extents(), __padding_stride_idx, __other_mapping)),
__unpadded_extent(detail::__construct_unpadded_extent_type(__other_mapping.extents(), std::integral_constant<rank_type, __extent_to_pad_idx>{}))
__unpadded_extent(detail::__construct_unpadded_extent_type(__other_mapping.extents(), std::integral_constant<rank_type, __extent_to_pad_idx>{})),
__actual_extents(__other_mapping.extents())
{}

/**
Expand All @@ -621,7 +628,8 @@ class layout_right_padded<padding_stride>::mapping {
MDSPAN_CONDITIONAL_EXPLICIT((extents_type::rank() > 1 && (padding_stride == dynamic_extent || detail::__padded_layout_padding_stride<typename _Mapping::layout_type>::value == dynamic_extent)))
constexpr mapping(const _Mapping &__other_mapping)
: __inner_mapping(detail::__inner_extents_type<__extent_to_pad_idx, extents_type, __actual_padding_stride>::template __construct_other<padding_stride>(__other_mapping.extents(), __padding_stride_idx, __other_mapping)),
__unpadded_extent(detail::__construct_unpadded_extent_type(__other_mapping.extents(), std::integral_constant<rank_type, __extent_to_pad_idx>{}))
__unpadded_extent(detail::__construct_unpadded_extent_type(__other_mapping.extents(), std::integral_constant<rank_type, __extent_to_pad_idx>{})),
__actual_extents(__other_mapping.extents())
{
static_assert(padding_stride == dynamic_extent
|| detail::__padded_layout_padding_stride<typename _Mapping::layout_type>::value == dynamic_extent
Expand All @@ -644,17 +652,13 @@ class layout_right_padded<padding_stride>::mapping {
MDSPAN_CONDITIONAL_EXPLICIT((!std::is_convertible_v<typename _Mapping::extents_type, extents_type>))
constexpr mapping(const _Mapping &__other_mapping) noexcept
: __inner_mapping(__other_mapping.extents()),
__unpadded_extent(detail::__construct_unpadded_extent_type(__other_mapping.extents(), std::integral_constant<rank_type, __extent_to_pad_idx>{}))
__unpadded_extent(detail::__construct_unpadded_extent_type(__other_mapping.extents(), std::integral_constant<rank_type, __extent_to_pad_idx>{})),
__actual_extents(__other_mapping.extents())
{}

constexpr extents_type extents() const noexcept
constexpr const extents_type &extents() const noexcept
{
if constexpr (extents_type::rank() == size_t(0))
{
return {};
} else {
return detail::__substitute_extents<__extent_to_pad_idx, __inner_extents_type, __unpadded_extent_type::static_extent(0)>::template __construct_with_type<extents_type>(__inner_mapping.extents(), __unpadded_extent);
}
return __actual_extents;
}

constexpr std::array<index_type, extents_type::rank()>
Expand Down

0 comments on commit d0bcf74

Please sign in to comment.