[mdspan.layout.reqmts]

# 23 Containers library [[containers]](./#containers)

## 23.7 Views [[views]](views#mdspan.layout.reqmts)

### 23.7.3 Multidimensional access [[views.multidim]](views.multidim#mdspan.layout.reqmts)

#### 23.7.3.4 Layout mapping [[mdspan.layout]](mdspan.layout#reqmts)

#### 23.7.3.4.2 Requirements [mdspan.layout.reqmts]

[1](#1)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L21594)

A type M meets the [*layout mapping*](#def:layout_mapping "23.7.3.4.2 Requirements [mdspan.layout.reqmts]") requirements if

- [(1.1)](#1.1)

M models [copyable](concepts.object#concept:copyable "18.6 Object concepts [concepts.object]") and [equality_comparable](concept.equalitycomparable#concept:equality_comparable "18.5.4 Concept equality_­comparable [concept.equalitycomparable]"),

- [(1.2)](#1.2)

is_nothrow_move_constructible_v<M> is true,

- [(1.3)](#1.3)

is_nothrow_move_assignable_v<M> is true,

- [(1.4)](#1.4)

is_nothrow_swappable_v<M> is true, and

- [(1.5)](#1.5)

the following types and expressions are well-formed and
have the specified semantics.

[ð](#itemdecl:1)

`typename M::extents_type
`

[2](#2)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L21616)

*Result*: A type that is a specialization of extents[.](#2.sentence-1)

[ð](#itemdecl:2)

`typename M::index_type
`

[3](#3)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L21626)

*Result*: typename M​::​extents_type​::​index_type[.](#3.sentence-1)

[ð](#itemdecl:3)

`typename M::rank_type
`

[4](#4)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L21636)

*Result*: typename M​::​extents_type​::​rank_type[.](#4.sentence-1)

[ð](#itemdecl:4)

`typename M::layout_type
`

[5](#5)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L21646)

*Result*: A type MP that meets
the layout mapping policy requirements ([[mdspan.layout.policy.reqmts]](mdspan.layout.policy.reqmts "23.7.3.4.3 Layout mapping policy requirements")) and
for which *is-mapping-of*<MP, M> is true[.](#5.sentence-1)

[ð](#itemdecl:5)

`m.extents()
`

[6](#6)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L21658)

*Result*: const typename M​::​extents_type&

[ð](#itemdecl:6)

`m(i...)
`

[7](#7)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L21668)

*Result*: typename M​::​index_type

[8](#8)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L21672)

*Returns*: A nonnegative integer
less than numeric_limits<typename M​::​index_type>​::​max() and
less than or equal to numeric_limits<size_t>​::​max()[.](#8.sentence-1)

[ð](#itemdecl:7)

`m(i...) == m(static_cast<typename M::index_type>(i)...)
`

[9](#9)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L21684)

*Result*: bool

[10](#10)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L21688)

*Returns*: true

[ð](#itemdecl:8)

`m.required_span_size()
`

[11](#11)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L21698)

*Result*: typename M​::​index_type

[12](#12)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L21702)

*Returns*: If the size of the multidimensional index space m.extents() is 0,
then 0,
else 1 plus the maximum value of m(i...) for all i[.](#12.sentence-1)

[ð](#itemdecl:9)

`m.is_unique()
`

[13](#13)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L21714)

*Result*: bool

[14](#14)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L21718)

*Returns*: true only if
for every i and j where (i != j || ...) is true,m(i...) != m(j...) is true[.](#14.sentence-1)

[*Note [1](#note-1)*:

A mapping can return false even if the condition is met[.](#14.sentence-2)

For certain layouts, it is possibly not feasible to determine efficiently
whether the layout is unique[.](#14.sentence-3)

â *end note*]

[ð](#itemdecl:10)

`m.is_exhaustive()
`

[15](#15)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L21735)

*Result*: bool

[16](#16)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L21739)

*Returns*: true only if
for all k in the range [0, m.required_span_size()) there exists an i such that m(i...) equals k[.](#16.sentence-1)

[*Note [2](#note-2)*:

A mapping can return false even if the condition is met[.](#16.sentence-2)

For certain layouts, it is possibly not feasible to determine efficiently
whether the layout is exhaustive[.](#16.sentence-3)

â *end note*]

[ð](#itemdecl:11)

`m.is_strided()
`

[17](#17)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L21756)

*Result*: bool

[18](#18)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L21760)

*Returns*: true only if
for every rank index r of m.extents() there exists an integer sr such that,
for all i where (i+dr) is
a multidimensional index in m.extents() ([[mdspan.overview]](mdspan.overview "23.7.3.1 Overview")),m((i + dr)...) - m(i...) equals sr[.](#18.sentence-1)

[*Note [3](#note-3)*:

This implies that for a strided layoutm(i0,â¦,ik)=m(0,â¦,0)+i0Ãs0+â¯+ikÃsk[.](#18.sentence-2)

â *end note*]

[*Note [4](#note-4)*:

A mapping can return false even if the condition is met[.](#18.sentence-3)

For certain layouts, it is possibly not feasible to determine efficiently
whether the layout is strided[.](#18.sentence-4)

â *end note*]

[ð](#itemdecl:12)

`m.stride(r)
`

[19](#19)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L21784)

*Preconditions*: m.is_strided() is true[.](#19.sentence-1)

[20](#20)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L21788)

*Result*: typename M​::​index_type

[21](#21)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L21792)

*Returns*: sr as defined in m.is_strided() above[.](#21.sentence-1)

[22](#22)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L21796)

[*Note [5](#note-5)*:

It is not required for m.stride(r) to be well-formed
if m.extents().rank() is zero,
even if m.is_always_strided() is true[.](#22.sentence-1)

â *end note*]

[ð](#itemdecl:13)

`M::is_always_unique()
`

[23](#23)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L21809)

*Result*: A constant expression ([[expr.const]](expr.const "7.7 Constant expressions")) of type bool[.](#23.sentence-1)

[24](#24)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L21813)

*Returns*: true only if m.is_unique() is true for all possible objects m of type M[.](#24.sentence-1)

[*Note [6](#note-6)*:

A mapping can return false even if the above condition is met[.](#24.sentence-2)

For certain layout mappings, it is possibly not feasible to determine
whether every instance is unique[.](#24.sentence-3)

â *end note*]

[ð](#itemdecl:14)

`M::is_always_exhaustive()
`

[25](#25)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L21829)

*Result*: A constant expression ([[expr.const]](expr.const "7.7 Constant expressions")) of type bool[.](#25.sentence-1)

[26](#26)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L21833)

*Returns*: true only if m.is_exhaustive() is true for all possible objects m of type M[.](#26.sentence-1)

[*Note [7](#note-7)*:

A mapping can return false even if the above condition is met[.](#26.sentence-2)

For certain layout mappings, it is possibly not feasible to determine
whether every instance is exhaustive[.](#26.sentence-3)

â *end note*]

[ð](#itemdecl:15)

`M::is_always_strided()
`

[27](#27)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L21849)

*Result*: A constant expression ([[expr.const]](expr.const "7.7 Constant expressions")) of type bool[.](#27.sentence-1)

[28](#28)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L21853)

*Returns*: true only if m.is_strided() is true for all possible objects m of type M[.](#28.sentence-1)

[*Note [8](#note-8)*:

A mapping can return false even if the above condition is met[.](#28.sentence-2)

For certain layout mappings, it is possibly not feasible to determine
whether every instance is strided[.](#28.sentence-3)

â *end note*]
