Files
2025-10-25 03:02:53 +03:00

143 lines
4.4 KiB
Markdown
Raw Permalink Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

[mdspan.sub.helpers]
# 23 Containers library [[containers]](./#containers)
## 23.7 Views [[views]](views#mdspan.sub.helpers)
### 23.7.3 Multidimensional access [[views.multidim]](views.multidim#mdspan.sub.helpers)
#### 23.7.3.7 submdspan [[mdspan.sub]](mdspan.sub#helpers)
#### 23.7.3.7.4 Exposition-only helpers [mdspan.sub.helpers]
[🔗](#lib:de-ice)
`template<class T>
constexpr T de-ice(T val) { return val; }
template<[integral-constant-like](span.syn#concept:integral-constant-like "23.7.2.1Header <span> synopsis[span.syn]") T>
constexpr auto de-ice(T) { return T::value; }
template<class IndexType, size_t k, class... SliceSpecifiers>
constexpr IndexType first_(SliceSpecifiers... slices);
`
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L25378)
*Mandates*: IndexType is a signed or unsigned integer type[.](#1.sentence-1)
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L25383)
Let ϕk denote the following value:
- [(2.1)](#2.1)
sk if Sk models [convertible_to](concept.convertible#concept:convertible_to "18.4.4Concept convertible_­to[concept.convertible]")<IndexType>;
- [(2.2)](#2.2)
otherwise,get<0>(sk) if Sk models [*index-pair-like*](mdspan.syn#concept:index-pair-like "23.7.3.2Header <mdspan> synopsis[mdspan.syn]")<IndexType>;
- [(2.3)](#2.3)
otherwise,*de-ice*(sk.offset) if Sk is a specialization of strided_slice;
- [(2.4)](#2.4)
otherwise,0[.](#2.sentence-1)
[3](#3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L25401)
*Preconditions*: ϕk is representable as a value of type IndexType[.](#3.sentence-1)
[4](#4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L25405)
*Returns*: extents<IndexType>::*index-cast*(ϕk)[.](#4.sentence-1)
[🔗](#lib:last_)
`template<size_t k, class Extents, class... SliceSpecifiers>
constexpr auto last_(const Extents& src, SliceSpecifiers... slices);
`
[5](#5)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L25417)
*Mandates*: Extents is a specialization of extents[.](#5.sentence-1)
[6](#6)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L25421)
Let index_type be typename Extents::index_type[.](#6.sentence-1)
[7](#7)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L25425)
Let λk denote the following value:
- [(7.1)](#7.1)
*de-ice*(sk) + 1 if Sk models [convertible_to](concept.convertible#concept:convertible_to "18.4.4Concept convertible_­to[concept.convertible]")<index_type>; otherwise
- [(7.2)](#7.2)
get<1>(sk) if Sk models [*index-pair-like*](mdspan.syn#concept:index-pair-like "23.7.3.2Header <mdspan> synopsis[mdspan.syn]")<index_type>; otherwise
- [(7.3)](#7.3)
*de-ice*(sk.offset) +*de-ice*(sk.extent) if Sk is a specialization of strided_slice; otherwise
- [(7.4)](#7.4)
src.extent(k)[.](#7.sentence-1)
[8](#8)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L25443)
*Preconditions*: λk is representable as a value of type index_type[.](#8.sentence-1)
[9](#9)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L25447)
*Returns*: Extents::*index-cast*(λk)[.](#9.sentence-1)
[🔗](#lib:src-indices)
`template<class IndexType, size_t N, class... SliceSpecifiers>
constexpr array<IndexType, sizeof...(SliceSpecifiers)>
src-indices(const array<IndexType, N>& indices, SliceSpecifiers... slices);
`
[10](#10)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L25460)
*Mandates*: IndexType is a signed or unsigned integer type[.](#10.sentence-1)
[11](#11)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L25464)
*Returns*: An array<IndexType, sizeof...(SliceSpecifiers)> src_idx such that
for each k in the range [0, sizeof...(SliceSpecifiers)),src_idx[k] equals
- [(11.1)](#11.1)
*first_*<IndexType, k>(slices...) for each k where *map-rank*[k] equalsdynamic_extent,
- [(11.2)](#11.2)
otherwise,*first_*<IndexType, k>(slices...) +indices[*map-rank*[k]].