[mdspan.layout.rightpad] (original) (raw)

23 Containers library [containers]

23.7 Views [views]

23.7.3 Multidimensional access [views.multidim]

23.7.3.4 Layout mapping [mdspan.layout]

23.7.3.4.9 Class template layout_right_padded​::​mapping [mdspan.layout.rightpad]


23.7.3.4.9.1 Overview [mdspan.layout.rightpad.overview]

23.7.3.4.9.2 Exposition-only members [mdspan.layout.rightpad.expo]

23.7.3.4.9.3 Constructors [mdspan.layout.rightpad.cons]

23.7.3.4.9.4 Observers [mdspan.layout.rightpad.obs]


23.7.3.4.9.1 Overview [mdspan.layout.rightpad.overview]

layout_right_padded provides a layout mapping that behaves like layout_right​::​mapping, except that the padding stride stride(extents_type​::​rank() - 2)can be greater than or equal toextents_type​::​extent(extents_type​::​rank() - 1).

namespace std { template<size_t PaddingValue> template<class Extents> class layout_right_padded<PaddingValue>::mapping { public: static constexpr size_t padding_value = PaddingValue;using extents_type = Extents;using index_type = extents_type::index_type;using size_type = extents_type::size_type;using rank_type = extents_type::rank_type;using layout_type = layout_right_padded<PaddingValue>;private: static constexpr size_t rank_ = extents_type::rank(); static constexpr size_t last-static-extent = extents_type::static_extent(rank_ - 1);static constexpr size_t static-padding-stride = see below; public: constexpr mapping() noexcept : mapping(extents_type{}) {} constexpr mapping(const mapping&) noexcept = default;constexpr mapping(const extents_type&);template<class OtherIndexType> constexpr mapping(const extents_type&, OtherIndexType);template<class OtherExtents> constexpr explicit(!is_convertible_v<OtherExtents, extents_type>) mapping(const layout_right::mapping<OtherExtents>&);template<class OtherExtents> constexpr explicit(see below) mapping(const layout_stride::mapping<OtherExtents>&);template<class LayoutRightPaddedMapping> constexpr explicit(see below) mapping(const LayoutRightPaddedMapping&);template<class LayoutLeftPaddedMapping> constexpr explicit(see below) mapping(const LayoutLeftPaddedMapping&) noexcept;constexpr mapping& operator=(const mapping&) noexcept = default;constexpr const extents_type& extents() const noexcept { return extents_; } constexpr array<index_type, rank_> strides() const noexcept;constexpr index_type required_span_size() const noexcept;template<class... Indices> constexpr index_type operator()(Indices...) const noexcept;static constexpr bool is_always_unique() noexcept { return true; } static constexpr bool is_always_exhaustive() noexcept;static constexpr bool is_always_strided() noexcept { return true; } static constexpr bool is_unique() noexcept { return true; } constexpr bool is_exhaustive() const noexcept;static constexpr bool is_strided() noexcept { return true; } constexpr index_type stride(rank_type) const noexcept;template<class LayoutRightPaddedMapping> friend constexpr bool operator==(const mapping&, const LayoutRightPaddedMapping&) noexcept;private: index_type stride-rm2 = static-padding-stride; extents_type extents_{}; template<class... SliceSpecifiers> constexpr auto submdspan-mapping-impl(SliceSpecifiers...) const -> see below;template<class... SliceSpecifiers> friend constexpr auto submdspan_mapping(const mapping& src, SliceSpecifiers... slices) { return src.submdspan-mapping-impl(slices...);} };}

If Extents is not a specialization of extents, then the program is ill-formed.

layout_right_padded​::​mapping<E> is a trivially copyable type that models regular for each E.

Throughout [mdspan.layout.rightpad], let P_rank be the following size rank_ parameter pack of size_t values:

Mandates:

23.7.3.4.9.2 Exposition-only members [mdspan.layout.rightpad.expo]

static constexpr size_t _static-padding-stride_ = _see below_;

The value is

index_type _stride-rm2_ = _static-padding-stride_;

Recommended practice: Implementations should not store this value if static-padding-stride is not dynamic_extent.

[Note 1:

Using extents<index_type, _static-padding-stride_>instead of index_type as the type of _stride-rm2_would achieve this.

— _end note_]

23.7.3.4.9.3 Constructors [mdspan.layout.rightpad.cons]

constexpr mapping(const extents_type& ext);

Preconditions:

Effects:

template<class OtherIndexType> constexpr mapping(const extents_type& ext, OtherIndexType pad);

Constraints:

Preconditions:

Effects: Direct-non-list-initializes extents_ with ext, and if rank_ is greater than one, direct-non-list-initializes stride-rm2 with_LEAST-MULTIPLE-AT-LEAST_(pad, ext.extent(rank_ - 1)).

template<class OtherExtents> constexpr explicit(!is_convertible_v<OtherExtents, extents_type>) mapping(const layout_right::mapping<OtherExtents>& other);

Constraints: is_constructible_v<extents_type, OtherExtents> is true.

Mandates: If OtherExtents​::​rank() is greater than 1, then(static-padding-stride == dynamic_extent) || (OtherExtents::static_extent(rank_ - 1) == dynamic_extent) || (static-padding-stride == OtherExtents::static_extent(rank_ - 1)) is true.

Preconditions:

Effects: Equivalent to mapping(other.extents()).

template<class OtherExtents> constexpr explicit(_see below_) mapping(const layout_stride::mapping<OtherExtents>& other);

Constraints: is_constructible_v<extents_type, OtherExtents> is true.

Preconditions:

Effects:

Remarks: The expression inside explicit is equivalent to:!(rank_ == 0 && is_convertible_v<OtherExtents, extents_type>)

template<class LayoutRightPaddedMapping> constexpr explicit(_see below_) mapping(const LayoutRightPaddedMapping& other);

Constraints:

Mandates: If rank_ is greater than 1, thenpadding_value == dynamic_extent ||LayoutRightPaddedMapping::padding_value == dynamic_extent ||padding_value == LayoutRightPaddedMapping::padding_valueis true.

Preconditions:

Effects:

Remarks: The expression inside explicit is equivalent to:!is_convertible_v<typename LayoutRightPaddedMapping::extents_type, extents_type> || rank_ > 1 && (padding_value != dynamic_extent || LayoutRightPaddedMapping::padding_value == dynamic_extent)

template<class LayoutLeftPaddedMapping> constexpr explicit(_see below_) mapping(const LayoutLeftPaddedMapping& other) noexcept;

Constraints:

Preconditions: other.required_span_size() is representable as a value of type index_type.

Effects: Direct-non-list-initializes extents_ with other.extents().

Remarks: The expression inside explicit is equivalent to:!is_convertible_v<typename LayoutLeftPaddedMapping::extents_type, extents_type>

[Note 1:

Neither the input mapping nor the mapping to be constructed uses the padding stride in the rank-0 or rank-1 case, so the padding stride affects neither the constraints nor the preconditions.

— _end note_]

23.7.3.4.9.4 Observers [mdspan.layout.rightpad.obs]

constexpr array<index_type, _rank_> strides() const noexcept;

Returns: array<index_type, _rank__>(stride(P_rank)...).

constexpr index_type required_span_size() const noexcept;

Returns: 0 if the multidimensional index space extents_ is empty, otherwise (*this)(extents_.extent(P_rank) - index_type(1)...) + 1.

template<class... Indices> constexpr size_t operator()(Indices... idxs) const noexcept;

Constraints:

Preconditions: extents_type​::​index-cast(idxs) is a multidimensional index in extents() ([mdspan.overview]).

Returns: ((static_cast<index_type>(idxs) * stride(P_rank)) + ... + 0).

static constexpr bool is_always_exhaustive() noexcept;

Returns:

constexpr bool is_exhaustive() const noexcept;

Returns: true if rank_ equals zero or one; otherwise,extents_.extent(rank_ - 1) == stride(rank_ - 2)

constexpr index_type stride(rank_type r) const noexcept;

Preconditions: r is smaller than rank_.

Returns:

template<class LayoutRightPaddedMapping> friend constexpr bool operator==(const mapping& x, const LayoutRightPaddedMapping& y) noexcept;

Constraints:

Returns: true if x.extents() == y.extents() is true and_rank__ < 2 || x.stride(rank_ - 2) == y.stride(rank_ - 2) is true.

Otherwise, false.