[mdspan.sub.extents]

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

## 23.7 Views [[views]](views#mdspan.sub.extents)

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

#### 23.7.3.7 submdspan [[mdspan.sub]](mdspan.sub#extents)

#### 23.7.3.7.5 submdspan_extents function [mdspan.sub.extents]

[ð](#lib:submdspan_extents)

`template<class IndexType, size_t... Extents, class... SliceSpecifiers>
  constexpr auto submdspan_extents(const extents<IndexType, Extents...>& src,
                                   SliceSpecifiers... slices);
`

[1](#1)

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

*Constraints*: sizeof...(slices) equals sizeof...(Extents)[.](#1.sentence-1)

[2](#2)

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

*Mandates*: For each rank index k of src.extents(),
exactly one of the following is true:

- [(2.1)](#2.1)

Sk models [convertible_to](concept.convertible#concept:convertible_to "18.4.4 Concept convertible_­to [concept.convertible]")<IndexType>,

- [(2.2)](#2.2)

Sk models [*index-pair-like*](mdspan.syn#concept:index-pair-like "23.7.3.2 Header <mdspan> synopsis [mdspan.syn]")<IndexType>,

- [(2.3)](#2.3)

is_convertible_v<Sk, full_extent_t> is true, or

- [(2.4)](#2.4)

Sk is a specialization of strided_slice[.](#2.sentence-1)

[3](#3)

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

*Preconditions*: For each rank index k of src.extents(),
all of the following are true:

- [(3.1)](#3.1)

if Sk is a specialization of strided_slice
  * [(3.1.1)](#3.1.1)

sk.extent=0, or

  * [(3.1.2)](#3.1.2)

sk.stride>0

- [(3.2)](#3.2)

0 â¤ *first_*<IndexType, k>(slices...) â¤ *last_*<k>(src, slices...) â¤ src.extent(k)

[4](#4)

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

Let SubExtents be a specialization of extents such that:

- [(4.1)](#4.1)

SubExtents​::​rank() equals the number of k such thatSk does not model [convertible_to](concept.convertible#concept:convertible_to "18.4.4 Concept convertible_­to [concept.convertible]")<IndexType>; and

- [(4.2)](#4.2)

for each rank index k of Extents such that*map-rank*[k] != dynamic_extent is true,SubExtents​::​static_extent(*map-rank*[k]) equals:
  * [(4.2.1)](#4.2.1)

Extents​::​static_extent(k) if is_convertible_v<Sk, full_extent_t> is true;
 otherwise

  * [(4.2.2)](#4.2.2)

*de-ice*(tuple_element_t<1, Sk>()) -*de-ice*(tuple_element_t<0, Sk>()) if Sk models [*index-pair-like*](mdspan.syn#concept:index-pair-like "23.7.3.2 Header <mdspan> synopsis [mdspan.syn]")<IndexType>, and
 both tuple_element_t<0, Sk> and tuple_element_t<1, Sk> model [*integral-constant-like*](span.syn#concept:integral-constant-like "23.7.2.1 Header <span> synopsis [span.syn]"); otherwise

  * [(4.2.3)](#4.2.3)

0,
 if Sk is a specialization of strided_slice, whose extent_type models *integral-constant-like*,
 for which extent_type() equals zero; otherwise

  * [(4.2.4)](#4.2.4)

1 + (*de-ice*(Sk​::​extent_type()) - 1) /*de-ice*(Sk​::​stride_type()),
 if Sk is a specialization of strided_slice whose extent_type and stride_type model *integral-constant-like*;

  * [(4.2.5)](#4.2.5)

otherwise, dynamic_extent[.](#4.sentence-1)

[5](#5)

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

*Returns*: A value ext of type SubExtents such that
for each k for which *map-rank*[k] != dynamic_extent is true,ext.extent(*map-rank*[k]) equals:

- [(5.1)](#5.1)

sk.extent == 0 ? 0 : 1 + (*de-ice*(sk.extent) - 1) / *de-ice*(sk.stride) if Sk is a specialization of strided_slice,

- [(5.2)](#5.2)

otherwise,*last_*<k>(src, slices...) - *first_*<IndexType, k>(slices...)[.](#5.sentence-1)
