[mdspan.layout.left] (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.5 Class template layout_left::mapping [mdspan.layout.left]
23.7.3.4.5.1 Overview [mdspan.layout.left.overview]
layout_left provides a layout mapping where the leftmost extent has stride 1, and strides increase left-to-right as the product of extents.
namespace std { template<class Extents> class layout_left::mapping { public: 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_left;constexpr mapping() noexcept = default;constexpr mapping(const mapping&) noexcept = default;constexpr mapping(const extents_type&) noexcept;template<class OtherExtents> constexpr explicit(!is_convertible_v<OtherExtents, extents_type>) mapping(const mapping<OtherExtents>&) noexcept;template<class OtherExtents> constexpr explicit(!is_convertible_v<OtherExtents, extents_type>) mapping(const layout_right::mapping<OtherExtents>&) noexcept;template<class LayoutLeftPaddedMapping> constexpr explicit(!is_convertible_v<typename LayoutLeftPaddedMapping::extents_type, extents_type>) mapping(const LayoutLeftPaddedMapping&) noexcept;template<class OtherExtents> constexpr explicit(extents_type::rank() > 0) mapping(const layout_stride::mapping<OtherExtents>&);constexpr mapping& operator=(const mapping&) noexcept = default;constexpr const extents_type& extents() const noexcept { return extents_; } 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 { return true; } static constexpr bool is_always_strided() noexcept { return true; } static constexpr bool is_unique() noexcept { return true; } static constexpr bool is_exhaustive() noexcept { return true; } static constexpr bool is_strided() noexcept { return true; } constexpr index_type stride(rank_type) const noexcept;template<class OtherExtents> friend constexpr bool operator==(const mapping&, const mapping<OtherExtents>&) noexcept;private: 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_left::mapping<E> is a trivially copyable type that models regular for each E.
Mandates: If Extents::rank_dynamic() == 0 is true, then the size of the multidimensional index space Extents()is representable as a value of type typename Extents::index_type.
23.7.3.4.5.2 Constructors [mdspan.layout.left.cons]
constexpr mapping(const extents_type& e) noexcept;
Preconditions: The size of the multidimensional index space eis representable as a value of type index_type ([basic.fundamental]).
Effects: Direct-non-list-initializes extents_ with e.
template<class OtherExtents> constexpr explicit(!is_convertible_v<OtherExtents, extents_type>) mapping(const mapping<OtherExtents>& other) noexcept;
Constraints: is_constructible_v<extents_type, OtherExtents> is true.
Preconditions: other.required_span_size() is representable as a value of type index_type ([basic.fundamental]).
Effects: Direct-non-list-initializes extents_ with other.extents().
template<class OtherExtents> constexpr explicit(!is_convertible_v<OtherExtents, extents_type>) mapping(const layout_right::mapping<OtherExtents>& other) noexcept;
Constraints:
- extents_type::rank() <= 1 is true, and
- is_constructible_v<extents_type, OtherExtents> is true.
Preconditions: other.required_span_size() is representable as a value of type index_type ([basic.fundamental]).
Effects: Direct-non-list-initializes extents_ with other.extents().
template<class LayoutLeftPaddedMapping> constexpr explicit(!is_convertible_v<typename LayoutLeftPaddedMapping::extents_type, extents_type>) mapping(const LayoutLeftPaddedMapping&) noexcept;
Constraints:
- is-layout-left-padded-mapping-of<LayoutLeftPaddedMapping> is true.
- is_constructible_v<extents_type, typename LayoutLeftPaddedMapping::extents_type>
is true.
Mandates: If
- Extents::rank() is greater than one,
- Extents::static_extent(0) does not equal dynamic_extent, and
- LayoutLeftPaddedMapping::_static-padding-stride_does not equal dynamic_extent,
then Extents::static_extent(0) equalsLayoutLeftPaddedMapping::static-padding-stride.
Preconditions:
- If extents_type::rank() > 1 is true, then other.stride(1) equals other.extents(0).
- other.required_span_size() is representable as a value of type index_type.
Effects: Direct-non-list-initializes extents_ with other.extents().
template<class OtherExtents> constexpr explicit(extents_type::rank() > 0) mapping(const layout_stride::mapping<OtherExtents>& other);
Constraints: is_constructible_v<extents_type, OtherExtents> is true.
Preconditions:
- If extents_type::rank() > 0 is true, then for all r in the range [0, extents_type::rank()),other.stride(r) equalsother.extents().fwd-prod-of-extents(r), and
- other.required_span_size() is representable as a value of type index_type ([basic.fundamental]).
Effects: Direct-non-list-initializes extents_ with other.extents().
23.7.3.4.5.3 Observers [mdspan.layout.left.obs]
constexpr index_type required_span_size() const noexcept;
Returns: extents().fwd-prod-of-extents(extents_type::rank()).
template<class... Indices> constexpr index_type operator()(Indices... i) const noexcept;
Constraints:
- sizeof...(Indices) == extents_type::rank() is true,
- (is_convertible_v<Indices, index_type> && ...) is true, and
- (is_nothrow_constructible_v<index_type, Indices> && ...) is true.
Preconditions: extents_type::index-cast(i) is a multidimensional index in extents_ ([mdspan.overview]).
Effects: Let P be a parameter pack such thatis_same_v<index_sequence_for<Indices...>, index_sequence<P...>> is true.
Equivalent to:return ((static_cast<index_type>(i) * stride(P)) + ... + 0);
constexpr index_type stride(rank_type i) const;
Constraints: extents_type::rank() > 0 is true.
Preconditions: i < extents_type::rank() is true.
Returns: extents().fwd-prod-of-extents(i).
template<class OtherExtents> friend constexpr bool operator==(const mapping& x, const mapping<OtherExtents>& y) noexcept;
Constraints: extents_type::rank() == OtherExtents::rank() is true.
Effects: Equivalent to: return x.extents() == y.extents();