[mdspan.mdspan.cons]

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

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

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

#### 23.7.3.6 Class template mdspan [[mdspan.mdspan]](mdspan.mdspan#cons)

#### 23.7.3.6.2 Constructors [mdspan.mdspan.cons]

[ð](#lib:mdspan,constructor)

`constexpr mdspan();
`

[1](#1)

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

*Constraints*: 

- [(1.1)](#1.1)

  rank_dynamic() > 0 is true[.](#1.1.sentence-1)

- [(1.2)](#1.2)

  is_default_constructible_v<data_handle_type> is true[.](#1.2.sentence-1)

- [(1.3)](#1.3)

  is_default_constructible_v<mapping_type> is true[.](#1.3.sentence-1)

- [(1.4)](#1.4)

  is_default_constructible_v<accessor_type> is true[.](#1.4.sentence-1)

[2](#2)

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

*Preconditions*: [0, *map_*.required_span_size()) is
an accessible range of *ptr_* and *acc_* for the values of *map_* and *acc_* after the invocation of this constructor[.](#2.sentence-1)

[3](#3)

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

*Effects*: Value-initializes *ptr_*, *map_*, and *acc_*[.](#3.sentence-1)

[ð](#lib:mdspan,constructor_)

`template<class... OtherIndexTypes>
  constexpr explicit mdspan(data_handle_type p, OtherIndexTypes... exts);
`

[4](#4)

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

Let N be sizeof...(OtherIndexTypes)[.](#4.sentence-1)

[5](#5)

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

*Constraints*: 

- [(5.1)](#5.1)

(is_convertible_v<OtherIndexTypes, index_type> && ...) is true,

- [(5.2)](#5.2)

(is_nothrow_constructible<index_type, OtherIndexTypes> && ...) is true,

- [(5.3)](#5.3)

N == rank() || N == rank_dynamic() is true,

- [(5.4)](#5.4)

is_constructible_v<mapping_type, extents_type> is true, and

- [(5.5)](#5.5)

is_default_constructible_v<accessor_type> is true[.](#5.sentence-1)

[6](#6)

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

*Preconditions*: [0, *map_*.required_span_size()) is
an accessible range of p and *acc_* for the values of *map_* and *acc_* after the invocation of this constructor[.](#6.sentence-1)

[7](#7)

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

*Effects*: 

- [(7.1)](#7.1)

Direct-non-list-initializes *ptr_* with std​::​move(p),

- [(7.2)](#7.2)

direct-non-list-initializes *map_* withextents_type(static_cast<index_type>(std​::​move(exts​))...), and

- [(7.3)](#7.3)

value-initializes *acc_*[.](#7.sentence-1)

[ð](#lib:mdspan,constructor__)

`template<class OtherIndexType, size_t N>
  constexpr explicit(N != rank_dynamic())
    mdspan(data_handle_type p, span<OtherIndexType, N> exts);
template<class OtherIndexType, size_t N>
  constexpr explicit(N != rank_dynamic())
    mdspan(data_handle_type p, const array<OtherIndexType, N>& exts);
`

[8](#8)

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

*Constraints*: 

- [(8.1)](#8.1)

is_convertible_v<const OtherIndexType&, index_type> is true,

- [(8.2)](#8.2)

is_nothrow_constructible_v<index_type, const OtherIndexType&> is true,

- [(8.3)](#8.3)

N == rank() || N == rank_dynamic() is true,

- [(8.4)](#8.4)

is_constructible_v<mapping_type, extents_type> is true, and

- [(8.5)](#8.5)

is_default_constructible_v<accessor_type> is true[.](#8.sentence-1)

[9](#9)

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

*Preconditions*: [0, *map_*.required_span_size()) is
an accessible range of p and *acc_* for the values of *map_* and *acc_* after the invocation of this constructor[.](#9.sentence-1)

[10](#10)

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

*Effects*: 

- [(10.1)](#10.1)

Direct-non-list-initializes *ptr_* with std​::​move(p),

- [(10.2)](#10.2)

direct-non-list-initializes *map_* with extents_type(exts), and

- [(10.3)](#10.3)

value-initializes *acc_*[.](#10.sentence-1)

[ð](#lib:mdspan,constructor___)

`constexpr mdspan(data_handle_type p, const extents_type& ext);
`

[11](#11)

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

*Constraints*: 

- [(11.1)](#11.1)

is_constructible_v<mapping_type, const extents_type&> is true, and

- [(11.2)](#11.2)

is_default_constructible_v<accessor_type> is true[.](#11.sentence-1)

[12](#12)

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

*Preconditions*: [0, *map_*.required_span_size()) is
an accessible range of p and *acc_* for the values of *map_* and *acc_* after the invocation of this constructor[.](#12.sentence-1)

[13](#13)

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

*Effects*: 

- [(13.1)](#13.1)

Direct-non-list-initializes *ptr_* with std​::​move(p),

- [(13.2)](#13.2)

direct-non-list-initializes *map_* with ext, and

- [(13.3)](#13.3)

value-initializes *acc_*[.](#13.sentence-1)

[ð](#lib:mdspan,constructor____)

`constexpr mdspan(data_handle_type p, const mapping_type& m);
`

[14](#14)

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

*Constraints*: is_default_constructible_v<accessor_type> is true[.](#14.sentence-1)

[15](#15)

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

*Preconditions*: [0, m.required_span_size()) is
an accessible range of p and *acc_* for the value of *acc_* after the invocation of this constructor[.](#15.sentence-1)

[16](#16)

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

*Effects*: 

- [(16.1)](#16.1)

Direct-non-list-initializes *ptr_* with std​::​move(p),

- [(16.2)](#16.2)

direct-non-list-initializes *map_* with m, and

- [(16.3)](#16.3)

value-initializes *acc_*[.](#16.sentence-1)

[ð](#lib:mdspan,constructor_____)

`constexpr mdspan(data_handle_type p, const mapping_type& m, const accessor_type& a);
`

[17](#17)

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

*Preconditions*: [0, m.required_span_size()) is
an accessible range of p and a[.](#17.sentence-1)

[18](#18)

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

*Effects*: 

- [(18.1)](#18.1)

Direct-non-list-initializes *ptr_* with std​::​move(p),

- [(18.2)](#18.2)

direct-non-list-initializes *map_* with m, and

- [(18.3)](#18.3)

direct-non-list-initializes *acc_* with a[.](#18.sentence-1)

[ð](#lib:mdspan,constructor______)

`template<class OtherElementType, class OtherExtents,
         class OtherLayoutPolicy, class OtherAccessor>
  constexpr explicit(see below)
    mdspan(const mdspan<OtherElementType, OtherExtents,
                        OtherLayoutPolicy, OtherAccessor>& other);
`

[19](#19)

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

*Constraints*: 

- [(19.1)](#19.1)

is_constructible_v<mapping_type, const OtherLayoutPolicy​::​template mapping<Oth-  
erExtents>&> is true, and

- [(19.2)](#19.2)

is_constructible_v<accessor_type, const OtherAccessor&> is true[.](#19.sentence-1)

[20](#20)

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

*Mandates*: 

- [(20.1)](#20.1)

is_constructible_v<data_handle_type, const OtherAccessor​::​data_handle_type&> is  
true, and

- [(20.2)](#20.2)

is_constructible_v<extents_type, OtherExtents> is true[.](#20.sentence-1)

[21](#21)

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

*Preconditions*: [0, *map_*.required_span_size()) is
an accessible range of *ptr_* and *acc_* for values of *ptr_*, *map_*, and *acc_* after the invocation of this constructor[.](#21.sentence-1)

[22](#22)

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

*Hardened preconditions*: For each rank index r of extents_type,static_extent(r) == dynamic_extent || static_extent(r) == other.extent(r) is true[.](#22.sentence-1)

[23](#23)

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

*Effects*: 

- [(23.1)](#23.1)

Direct-non-list-initializes *ptr_* with other.*ptr_*,

- [(23.2)](#23.2)

direct-non-list-initializes *map_* with other.*map_*, and

- [(23.3)](#23.3)

direct-non-list-initializes *acc_* with other.*acc_*[.](#23.sentence-1)

[24](#24)

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

*Remarks*: The expression inside explicit is equivalent to:!is_convertible_v<const OtherLayoutPolicy::template mapping<OtherExtents>&, mapping_type>|| !is_convertible_v<const OtherAccessor&, accessor_type>
