[mdspan.layout.stride.cons]

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

## 23.7 Views [[views]](views#mdspan.layout.stride.cons)

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

#### 23.7.3.4 Layout mapping [[mdspan.layout]](mdspan.layout#stride.cons)

#### 23.7.3.4.7 Class template layout_stride​::​mapping [[mdspan.layout.stride]](mdspan.layout.stride#cons)

#### 23.7.3.4.7.3 Constructors [mdspan.layout.stride.cons]

[ð](#lib:layout_stride::mapping,constructor)

`constexpr mapping() noexcept;
`

[1](#1)

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

*Preconditions*: layout_right​::​mapping<extents_type>().required_span_size() is representable as a value of type index_type ([[basic.fundamental]](basic.fundamental "6.9.2 Fundamental types"))[.](#1.sentence-1)

[2](#2)

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

*Effects*: Direct-non-list-initializes *extents_* with extents_type(), and
for all d in the range [0, *rank_*),
direct-non-list-initializes *strides_*[d] withlayout_right​::​mapping<extents_type>().stride(d)[.](#2.sentence-1)

[ð](#lib:layout_stride::mapping,constructor_)

`template<class OtherIndexType>
  constexpr mapping(const extents_type& e, span<OtherIndexType, rank_> s) noexcept;
template<class OtherIndexType>
  constexpr mapping(const extents_type& e, const array<OtherIndexType, rank_>& s) noexcept;
`

[3](#3)

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

*Constraints*: 

- [(3.1)](#3.1)

is_convertible_v<const OtherIndexType&, index_type> is true, and

- [(3.2)](#3.2)

is_nothrow_constructible_v<index_type, const OtherIndexType&> is true[.](#3.sentence-1)

[4](#4)

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

*Preconditions*: 

- [(4.1)](#4.1)

  The result of converting s[i] to index_type is greater than 0 for all i in the range [0, *rank_*)[.](#4.1.sentence-1)

- [(4.2)](#4.2)

  *REQUIRED-SPAN-SIZE*(e, s) is representable
as a value of type index_type ([[basic.fundamental]](basic.fundamental "6.9.2 Fundamental types"))[.](#4.2.sentence-1)

- [(4.3)](#4.3)

  If *rank_* is greater than 0,
then there exists a permutation P of the integers
in the range [0, *rank_*),
such that s[pi] >= s[piâ1] * e.extent(piâ1) is true for all i in the range [1, *rank_*),
where pi is the ith element of P[.](#4.3.sentence-1)
  [*Note [1](#note-1)*:
  For layout_stride,
this condition is necessary and sufficient
for is_unique() to be true[.](#4.3.sentence-2)
 â *end note*]

[5](#5)

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

*Effects*: Direct-non-list-initializes *extents_* with e, and
for all d in the range [0, *rank_*),
direct-non-list-initializes strides_[d] with as_const(s[d])[.](#5.sentence-1)

[ð](#lib:layout_stride::mapping,constructor__)

`template<class StridedLayoutMapping>
  constexpr explicit(see below)
    mapping(const StridedLayoutMapping& other) noexcept;
`

[6](#6)

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

*Constraints*: 

- [(6.1)](#6.1)

  [*layout-mapping-alike*](mdspan.layout.stride.expo#concept:layout-mapping-alike "23.7.3.4.7.2 Exposition-only helpers [mdspan.layout.stride.expo]")<StridedLayoutMapping> is satisfied[.](#6.1.sentence-1)

- [(6.2)](#6.2)

  is_constructible_v<extents_type, typename StridedLayoutMapping​::​extents_type> is  
  true[.](#6.2.sentence-2)

- [(6.3)](#6.3)

  StridedLayoutMapping​::​is_always_unique() is true[.](#6.3.sentence-1)

- [(6.4)](#6.4)

  StridedLayoutMapping​::​is_always_strided() is true[.](#6.4.sentence-1)

[7](#7)

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

*Preconditions*: 

- [(7.1)](#7.1)

StridedLayoutMapping meets the layout mapping requirements ([[mdspan.layout.reqmts]](mdspan.layout.reqmts "23.7.3.4.2 Requirements")),

- [(7.2)](#7.2)

other.stride(r) > 0 is true for every rank index r of extents(),

- [(7.3)](#7.3)

other.required_span_size() is representable as
a value of type index_type ([[basic.fundamental]](basic.fundamental "6.9.2 Fundamental types")), and

- [(7.4)](#7.4)

*OFFSET*(other) == 0 is true[.](#7.sentence-1)

[8](#8)

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

*Effects*: Direct-non-list-initializes *extents_* with other.extents(), and
for all d in the range [0, *rank_*),
direct-non-list-initializes *strides_*[d] with other.stride(d)[.](#8.sentence-1)

[9](#9)

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

Remarks: The expression inside explicit is equivalent to:!(is_convertible_v<typename StridedLayoutMapping::extents_type, extents_type> &&(*is-mapping-of*<layout_left, StridedLayoutMapping> ||*is-mapping-of*<layout_right, StridedLayoutMapping> ||*is-layout-left-padded-mapping-of*<StridedLayoutMapping> ||*is-layout-right-padded-mapping-of*<StridedLayoutMapping> ||*is-mapping-of*<layout_stride, StridedLayoutMapping>))
