[mdspan.layout.leftpad.cons]

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

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

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

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

#### 23.7.3.4.8 Class template layout_left_padded​::​mapping [[mdspan.layout.leftpad]](mdspan.layout.leftpad#cons)

#### 23.7.3.4.8.3 Constructors [mdspan.layout.leftpad.cons]

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

`constexpr mapping(const extents_type& ext);
`

[1](#1)

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

*Preconditions*: 

- [(1.1)](#1.1)

  The size of the multidimensional index space ext is representable as
a value of type index_type[.](#1.1.sentence-1)

- [(1.2)](#1.2)

  If *rank_* is greater than one andpadding_value does not equal dynamic_extent,
then *LEAST-MULTIPLE-AT-LEAST*(padding_value, ext.extent(0)) is representable as a value of type *index_type*[.](#1.2.sentence-1)

- [(1.3)](#1.3)

  If *rank_* is greater than one andpadding_value does not equal dynamic_extent,
then the product of*LEAST-MULTIPLE-AT-LEAST*(padding_value, ext.extent(0)) and
all values ext.extent(k) with k in the range of [1, *rank_*)
is representable as a value of type index_type[.](#1.3.sentence-1)

[2](#2)

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

*Effects*: 

- [(2.1)](#2.1)

Direct-non-list-initializes *extents_* with ext; and

- [(2.2)](#2.2)

if *rank_* is greater than one,
direct-non-list-initializes *stride-1*
  * [(2.2.1)](#2.2.1)

with ext.extent(0) if padding_value is dynamic_extent,

  * [(2.2.2)](#2.2.2)

otherwise with*LEAST-MULTIPLE-AT-LEAST*(padding_value, ext.extent(0))[.](#2.sentence-1)

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

`template<class OtherIndexType>
constexpr mapping(const extents_type& ext, OtherIndexType pad);
`

[3](#3)

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

*Constraints*: 

- [(3.1)](#3.1)

  is_convertible_v<OtherIndexType, index_type> is true[.](#3.1.sentence-1)

- [(3.2)](#3.2)

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

[4](#4)

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

*Preconditions*: 

- [(4.1)](#4.1)

  pad is representable as a value of type index_type[.](#4.1.sentence-1)

- [(4.2)](#4.2)

  extents_type​::​index-cast(pad) is greater than zero[.](#4.2.sentence-1)

- [(4.3)](#4.3)

  If *rank_* is greater than one,
then *LEAST-MULTIPLE-AT-LEAST*(pad, ext.extent(0)) is representable as a value of type index_type.

- [(4.4)](#4.4)

  If *rank_* is greater than one,
then the product of*LEAST-MULTIPLE-AT-LEAST*(pad, ext.extent(0)) and
all values ext.extent(k) with k in the range of [1, *rank_*)
is representable as a value of type index_type[.](#4.4.sentence-1)

- [(4.5)](#4.5)

  If padding_value is not equal to dynamic_extent,padding_value equals extents_type​::​*index-cast*(pad)[.](#4.5.sentence-1)

[5](#5)

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

*Effects*: Direct-non-list-initializes *extents_* with ext, and
if *rank_* is greater than one,
direct-non-list-initializes *stride-1* with*LEAST-MULTIPLE-AT-LEAST*(pad, ext.extent(0))[.](#5.sentence-1)

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

`template<class OtherExtents>
  constexpr explicit(!is_convertible_v<OtherExtents, extents_type>)
    mapping(const layout_left::mapping<OtherExtents>& other);
`

[6](#6)

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

*Constraints*: is_constructible_v<extents_type, OtherExtents> is true[.](#6.sentence-1)

[7](#7)

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

*Mandates*: If OtherExtents​::​rank() is greater than 1, then(*static-padding-stride* == dynamic_extent) ||(OtherExtents::static_extent(0) == dynamic_extent) ||(*static-padding-stride* == OtherExtents::static_extent(0)) is true[.](#7.sentence-1)

[8](#8)

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

*Preconditions*: 

- [(8.1)](#8.1)

If extents_type​::​rank() > 1 is true andpadding_value == dynamic_extent is false,
then other.stride(1) equals*LEAST-MULTIPLE-AT-LEAST*(padding_value,
 extents_type::*index-cast*(other.extents().extent(0))) and

- [(8.2)](#8.2)

other.required_span_size() is representable as
a value of type index_type[.](#8.sentence-1)

[9](#9)

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

*Effects*: Equivalent to mapping(other.extents())[.](#9.sentence-1)

[ð](#lib:layout_left_padded::mapping,constructor___)

`template<class OtherExtents>
  constexpr explicit(rank_ > 0)
    mapping(const layout_stride::mapping<OtherExtents>& other);
`

[10](#10)

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

*Constraints*: is_constructible_v<extents_type, OtherExtents> is true[.](#10.sentence-1)

[11](#11)

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

*Preconditions*: 

- [(11.1)](#11.1)

  If *rank_* is greater than 1 andpadding_value does not equal dynamic_extent,
then other.stride(1) equals*LEAST-MULTIPLE-AT-LEAST*(padding_value,
 extents_type::*index-cast*(other.extents().extent(0)))

- [(11.2)](#11.2)

  If *rank_* is greater than 0,
then other.stride(0) equals 1[.](#11.2.sentence-1)

- [(11.3)](#11.3)

  If *rank_* is greater than 2,
then for all r in the range [2, *rank_*),other.stride(r) equals(other.extents().*fwd-prod-of-extents*(r) / other.extents().extent(0)) * other.stride(1)

- [(11.4)](#11.4)

  other.required_span_size() is representable as
a value of type *index_type*[.](#11.4.sentence-1)

[12](#12)

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

*Effects*: 

- [(12.1)](#12.1)

Direct-non-list-initializes *extents_* with other.extents() and

- [(12.2)](#12.2)

if *rank_* is greater than one,
direct-non-list-initializes *stride-1* withother.stride(1)[.](#12.sentence-1)

[ð](#lib:layout_left_padded::mapping,constructor____)

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

[13](#13)

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

*Constraints*: 

- [(13.1)](#13.1)

  *is-layout-left-padded-mapping-of*<LayoutLeftPaddedMapping> is true[.](#13.1.sentence-1)

- [(13.2)](#13.2)

  is_constructible_v<extents_type, typename LayoutLeftPaddedMapping​::​extents_type>  
is true[.](#13.2.sentence-1)

[14](#14)

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

*Mandates*: If *rank_* is greater than 1,
thenpadding_value == dynamic_extent || LayoutLeftPaddedMapping::padding_value == dynamic_extent || padding_value == LayoutLeftPaddedMapping::padding_value is true[.](#14.sentence-1)

[15](#15)

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

*Preconditions*: 

- [(15.1)](#15.1)

If *rank_* is greater than 1 andpadding_value does not equal dynamic_extent,
then other.stride(1) equals*LEAST-MULTIPLE-AT-LEAST*(padding_value,
 extents_type::*index-cast*(other.extent(0)))

- [(15.2)](#15.2)

other.required_span_size() is representable as
a value of type index_type[.](#15.sentence-1)

[16](#16)

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

*Effects*: 

- [(16.1)](#16.1)

Direct-non-list-initializes *extents_* with other.extents() and

- [(16.2)](#16.2)

if *rank_* is greater than one,
direct-non-list-initializes *stride-1* with other.stride(1)[.](#16.sentence-1)

[17](#17)

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

*Remarks*: The expression inside explicit is equivalent to:rank_> 1 &&(padding_value != dynamic_extent || LayoutLeftPaddedMapping::padding_value == dynamic_extent)

[ð](#lib:layout_left_padded::mapping,constructor_____)

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

[18](#18)

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

*Constraints*: 

- [(18.1)](#18.1)

  *is-layout-right-padded-mapping-of*<LayoutRightPaddedMapping> is true or  
*is-mapping-of*<layout_right, LayoutRightPaddedMapping> is true[.](#18.1.sentence-1)

- [(18.2)](#18.2)

  *rank_* equals zero or one[.](#18.2.sentence-1)

- [(18.3)](#18.3)

  is_constructible_v<extents_type, typename LayoutRightPaddedMapping​::​extents_-  
type> is true[.](#18.3.sentence-1)

[19](#19)

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

*Preconditions*: other.required_span_size() is representable as
a value of type index_type[.](#19.sentence-1)

[20](#20)

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

*Effects*: Direct-non-list-initializes *extents_* with other.extents()[.](#20.sentence-1)

[21](#21)

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

*Remarks*: The expression inside explicit is equivalent to:!is_convertible_v<typename LayoutRightPaddedMapping::extents_type, extents_type>

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

Neither the input mapping nor the mapping to be constructed
uses the padding stride in the rank-0 or rank-1 case,
so the padding stride does not affect
either the constraints or the preconditions[.](#21.sentence-2)

â *end note*]
