24 Containers library [containers]

24.7 Views [views]

24.7.3 Multidimensional access [views.multidim]

24.7.3.4 Layout mapping [mdspan.layout]

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

24.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 to extents_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 = typename extents_type::index_type; using size_type = typename extents_type::size_type; using rank_type = typename extents_type::rank_type; using layout_type = layout_right_padded<PaddingValue>; private: static constexpr size_t rank_ = extents_type::rank(); // exposition only static constexpr size_t last-static-extent = // exposition only extents_type::static_extent(rank_ - 1); // [mdspan.layout.rightpad.expo], exposition-only members static constexpr size_t static-padding-stride = see below; // exposition only public: // [mdspan.layout.rightpad.cons], constructors 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(rank_ > 0) 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; // [mdspan.layout.rightpad.obs], observers 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: // [mdspan.layout.rightpad.expo], exposition-only members index_type stride-rm2 = static-padding-stride; // exposition only extents_type extents_{}; // exposition only // [mdspan.sub.map], submdspan mapping specialization template<class... SliceSpecifiers> constexpr auto submdspan-mapping-impl(SliceSpecifiers...) const // exposition only -> 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:
  • the empty parameter pack, if rank_ equals zero;
  • otherwise, 0zu, if rank_ equals one;
  • otherwise, the parameter pack 0zu, 1zu, …, rank_- 1.
Mandates:
  • If rank_dynamic() == 0 is true, then the size of the multidimensional index space Extents() is representable as a value of type index_type.
  • padding_value is representable as a value of type index_type.
  • If
    • rank_ is greater than one,
    • padding_value does not equal dynamic_extent, and
    • last-static-extent does not equal dynamic_extent,
    then LEAST-MULTIPLE-AT-LEAST(padding_value, last-static-extent) is representable as a value of type size_t, and is representable as a value of type index_type.
  • If
    • rank_ is greater than one,
    • padding_value does not equal dynamic_extent, and
    • extents_type​::​static_extent(k) does not equal dynamic_extent for all k in the range [0, rank_),
    then the product of LEAST-MULTIPLE-AT-LEAST(padding_value, ext.static_extent(rank_ - 1)) and all values ext.static_extent(k) with k in the range of [0, rank_ - 1) is representable as a value of type size_t, and is representable as a value of type index_type.