318 lines
13 KiB
Markdown
318 lines
13 KiB
Markdown
[mdspan.layout.left]
|
||
|
||
# 23 Containers library [[containers]](./#containers)
|
||
|
||
## 23.7 Views [[views]](views#mdspan.layout.left)
|
||
|
||
### 23.7.3 Multidimensional access [[views.multidim]](views.multidim#mdspan.layout.left)
|
||
|
||
#### 23.7.3.4 Layout mapping [[mdspan.layout]](mdspan.layout#left)
|
||
|
||
#### 23.7.3.4.5 Class template layout_left::mapping [mdspan.layout.left]
|
||
|
||
#### [23.7.3.4.5.1](#overview) Overview [[mdspan.layout.left.overview]](mdspan.layout.left.overview)
|
||
|
||
[1](#overview-1)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L21916)
|
||
|
||
layout_left provides a layout mapping
|
||
where the leftmost extent has stride 1, and
|
||
strides increase left-to-right as the product of extents[.](#overview-1.sentence-1)
|
||
|
||
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; // [[mdspan.layout.left.cons]](#cons "23.7.3.4.5.2 Constructors"), constructorsconstexpr 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; // [[mdspan.layout.left.obs]](#obs "23.7.3.4.5.3 Observers"), observersconstexpr 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_*{}; // *exposition only*// [[mdspan.sub.map]](mdspan.sub.map "23.7.3.7.6 Specializations of submdspan_mapping"), submdspan mapping specializationtemplate<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...); }};}
|
||
|
||
[2](#overview-2)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L21990)
|
||
|
||
If Extents is not a specialization of extents,
|
||
then the program is ill-formed[.](#overview-2.sentence-1)
|
||
|
||
[3](#overview-3)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L21994)
|
||
|
||
layout_left::mapping<E> is a trivially copyable type
|
||
that models [regular](concepts.object#concept:regular "18.6 Object concepts [concepts.object]") for each E[.](#overview-3.sentence-1)
|
||
|
||
[4](#overview-4)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L21998)
|
||
|
||
*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[.](#overview-4.sentence-1)
|
||
|
||
#### [23.7.3.4.5.2](#cons) Constructors [[mdspan.layout.left.cons]](mdspan.layout.left.cons)
|
||
|
||
[ð](#lib:layout_left::mapping,constructor)
|
||
|
||
`constexpr mapping(const extents_type& e) noexcept;
|
||
`
|
||
|
||
[1](#cons-1)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L22012)
|
||
|
||
*Preconditions*: The size of the multidimensional index space e is representable as a value of type index_type ([[basic.fundamental]](basic.fundamental "6.9.2 Fundamental types"))[.](#cons-1.sentence-1)
|
||
|
||
[2](#cons-2)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L22017)
|
||
|
||
*Effects*: Direct-non-list-initializes *extents_* with e[.](#cons-2.sentence-1)
|
||
|
||
[ð](#lib:layout_left::mapping,constructor_)
|
||
|
||
`template<class OtherExtents>
|
||
constexpr explicit(!is_convertible_v<OtherExtents, extents_type>)
|
||
mapping(const mapping<OtherExtents>& other) noexcept;
|
||
`
|
||
|
||
[3](#cons-3)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L22030)
|
||
|
||
*Constraints*: is_constructible_v<extents_type, OtherExtents> is true[.](#cons-3.sentence-1)
|
||
|
||
[4](#cons-4)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L22034)
|
||
|
||
*Preconditions*: other.required_span_size() is representable as
|
||
a value of type index_type ([[basic.fundamental]](basic.fundamental "6.9.2 Fundamental types"))[.](#cons-4.sentence-1)
|
||
|
||
[5](#cons-5)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L22039)
|
||
|
||
*Effects*: Direct-non-list-initializes *extents_* with other.extents()[.](#cons-5.sentence-1)
|
||
|
||
[ð](#lib:layout_left::mapping,constructor__)
|
||
|
||
`template<class OtherExtents>
|
||
constexpr explicit(!is_convertible_v<OtherExtents, extents_type>)
|
||
mapping(const layout_right::mapping<OtherExtents>& other) noexcept;
|
||
`
|
||
|
||
[6](#cons-6)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L22052)
|
||
|
||
*Constraints*:
|
||
|
||
- [(6.1)](#cons-6.1)
|
||
|
||
extents_type::rank() <= 1 is true, and
|
||
|
||
- [(6.2)](#cons-6.2)
|
||
|
||
is_constructible_v<extents_type, OtherExtents> is true[.](#cons-6.sentence-1)
|
||
|
||
[7](#cons-7)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L22061)
|
||
|
||
*Preconditions*: other.required_span_size() is representable as
|
||
a value of type index_type ([[basic.fundamental]](basic.fundamental "6.9.2 Fundamental types"))[.](#cons-7.sentence-1)
|
||
|
||
[8](#cons-8)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L22066)
|
||
|
||
*Effects*: Direct-non-list-initializes *extents_* with other.extents()[.](#cons-8.sentence-1)
|
||
|
||
[ð](#lib:layout_left::mapping,constructor___)
|
||
|
||
`template<class LayoutLeftPaddedMapping>
|
||
constexpr explicit(!is_convertible_v<typename LayoutLeftPaddedMapping::extents_type,
|
||
extents_type>)
|
||
mapping(const LayoutLeftPaddedMapping&) noexcept;
|
||
`
|
||
|
||
[9](#cons-9)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L22080)
|
||
|
||
*Constraints*:
|
||
|
||
- [(9.1)](#cons-9.1)
|
||
|
||
*is-layout-left-padded-mapping-of*<LayoutLeftPaddedMapping> is true[.](#cons-9.1.sentence-1)
|
||
|
||
- [(9.2)](#cons-9.2)
|
||
|
||
is_constructible_v<extents_type, typename LayoutLeftPaddedMapping::extents_type>
|
||
is true[.](#cons-9.2.sentence-1)
|
||
|
||
[10](#cons-10)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L22089)
|
||
|
||
*Mandates*: If
|
||
|
||
- [(10.1)](#cons-10.1)
|
||
|
||
Extents::rank() is greater than one,
|
||
|
||
- [(10.2)](#cons-10.2)
|
||
|
||
Extents::static_extent(0) does not equal dynamic_extent, and
|
||
|
||
- [(10.3)](#cons-10.3)
|
||
|
||
LayoutLeftPaddedMapping::*static-padding-stride* does not equal dynamic_extent,
|
||
|
||
then Extents::static_extent(0) equalsLayoutLeftPaddedMapping::*static-padding-stride*[.](#cons-10.sentence-1)
|
||
|
||
[11](#cons-11)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L22104)
|
||
|
||
*Preconditions*:
|
||
|
||
- [(11.1)](#cons-11.1)
|
||
|
||
If extents_type::rank() > 1 is true,
|
||
then other.stride(1) equals other.extents(0)[.](#cons-11.1.sentence-1)
|
||
|
||
- [(11.2)](#cons-11.2)
|
||
|
||
other.required_span_size() is representable as
|
||
a value of type index_type[.](#cons-11.2.sentence-1)
|
||
|
||
[12](#cons-12)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L22115)
|
||
|
||
*Effects*: Direct-non-list-initializes extents_ with other.extents()[.](#cons-12.sentence-1)
|
||
|
||
[ð](#lib:layout_left::mapping,constructor____)
|
||
|
||
`template<class OtherExtents>
|
||
constexpr explicit(extents_type::rank() > 0)
|
||
mapping(const layout_stride::mapping<OtherExtents>& other);
|
||
`
|
||
|
||
[13](#cons-13)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L22128)
|
||
|
||
*Constraints*: is_constructible_v<extents_type, OtherExtents> is true[.](#cons-13.sentence-1)
|
||
|
||
[14](#cons-14)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L22132)
|
||
|
||
*Preconditions*:
|
||
|
||
- [(14.1)](#cons-14.1)
|
||
|
||
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
|
||
|
||
- [(14.2)](#cons-14.2)
|
||
|
||
other.required_span_size() is representable as
|
||
a value of type index_type ([[basic.fundamental]](basic.fundamental "6.9.2 Fundamental types"))[.](#cons-14.sentence-1)
|
||
|
||
[15](#cons-15)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L22145)
|
||
|
||
*Effects*: Direct-non-list-initializes *extents_* with other.extents()[.](#cons-15.sentence-1)
|
||
|
||
#### [23.7.3.4.5.3](#obs) Observers [[mdspan.layout.left.obs]](mdspan.layout.left.obs)
|
||
|
||
[ð](#lib:required_span_size,layout_left::mapping)
|
||
|
||
`constexpr index_type required_span_size() const noexcept;
|
||
`
|
||
|
||
[1](#obs-1)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L22158)
|
||
|
||
*Returns*: extents().*fwd-prod-of-extents*(extents_type::rank())[.](#obs-1.sentence-1)
|
||
|
||
[ð](#lib:operator(),layout_left::mapping)
|
||
|
||
`template<class... Indices>
|
||
constexpr index_type operator()(Indices... i) const noexcept;
|
||
`
|
||
|
||
[2](#obs-2)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L22170)
|
||
|
||
*Constraints*:
|
||
|
||
- [(2.1)](#obs-2.1)
|
||
|
||
sizeof...(Indices) == extents_type::rank() is true,
|
||
|
||
- [(2.2)](#obs-2.2)
|
||
|
||
(is_convertible_v<Indices, index_type> && ...) is true, and
|
||
|
||
- [(2.3)](#obs-2.3)
|
||
|
||
(is_nothrow_constructible_v<index_type, Indices> && ...) is true[.](#obs-2.sentence-1)
|
||
|
||
[3](#obs-3)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L22181)
|
||
|
||
*Preconditions*: extents_type::*index-cast*(i) is
|
||
a multidimensional index in *extents_* ([[mdspan.overview]](mdspan.overview "23.7.3.1 Overview"))[.](#obs-3.sentence-1)
|
||
|
||
[4](#obs-4)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L22186)
|
||
|
||
*Effects*: Let P be a parameter pack such thatis_same_v<index_sequence_for<Indices...>, index_sequence<P...>> is true[.](#obs-4.sentence-1)
|
||
|
||
Equivalent to:return ((static_cast<index_type>(i) * stride(P)) + ... + 0);
|
||
|
||
[ð](#lib:stride,layout_left::mapping)
|
||
|
||
`constexpr index_type stride(rank_type i) const noexcept;
|
||
`
|
||
|
||
[5](#obs-5)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L22205)
|
||
|
||
*Constraints*: extents_type::rank() > 0 is true[.](#obs-5.sentence-1)
|
||
|
||
[6](#obs-6)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L22209)
|
||
|
||
*Preconditions*: i < extents_type::rank() is true[.](#obs-6.sentence-1)
|
||
|
||
[7](#obs-7)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L22213)
|
||
|
||
*Returns*: extents().*fwd-prod-of-extents*(i)[.](#obs-7.sentence-1)
|
||
|
||
[ð](#lib:operator==,layout_left::mapping)
|
||
|
||
`template<class OtherExtents>
|
||
friend constexpr bool operator==(const mapping& x, const mapping<OtherExtents>& y) noexcept;
|
||
`
|
||
|
||
[8](#obs-8)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L22225)
|
||
|
||
*Constraints*: extents_type::rank() == OtherExtents::rank() is true[.](#obs-8.sentence-1)
|
||
|
||
[9](#obs-9)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L22229)
|
||
|
||
*Effects*: Equivalent to: return x.extents() == y.extents();
|