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

218 lines
5.7 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.extents.cons]
# 23 Containers library [[containers]](./#containers)
## 23.7 Views [[views]](views#mdspan.extents.cons)
### 23.7.3 Multidimensional access [[views.multidim]](views.multidim#mdspan.extents.cons)
#### 23.7.3.3 Class template extents [[mdspan.extents]](mdspan.extents#cons)
#### 23.7.3.3.3 Constructors [mdspan.extents.cons]
[🔗](#lib:extents,constructor)
`template<class OtherIndexType, size_t... OtherExtents>
constexpr explicit(see below)
extents(const extents<OtherIndexType, OtherExtents...>& other) noexcept;
`
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L21276)
*Constraints*:
- [(1.1)](#1.1)
sizeof...(OtherExtents) == rank() is true[.](#1.1.sentence-1)
- [(1.2)](#1.2)
((OtherExtents == dynamic_extent || Extents == dynamic_extent || OtherExtents ==
Extents) && ...) is true[.](#1.2.sentence-1)
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L21285)
*Preconditions*:
- [(2.1)](#2.1)
other.extent(r) equals Er for each r for which Er is a static extent, and
- [(2.2)](#2.2)
either
* [(2.2.1)](#2.2.1)
sizeof...(OtherExtents) is zero, or
* [(2.2.2)](#2.2.2)
other.extent(r) is representable as
a value of type index_type for every rank index r of other[.](#2.sentence-1)
[3](#3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L21302)
*Postconditions*: *this == other is true[.](#3.sentence-1)
[4](#4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L21306)
*Remarks*: The expression inside explicit is equivalent to:(((Extents != dynamic_extent) && (OtherExtents == dynamic_extent)) || ... ) ||(numeric_limits<index_type>::max() < numeric_limits<OtherIndexType>::max())
[🔗](#lib:extents,constructor_)
`template<class... OtherIndexTypes>
constexpr explicit extents(OtherIndexTypes... exts) noexcept;
`
[5](#5)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L21322)
Let N be sizeof...(OtherIndexTypes),
and let exts_arr bearray<index_type, N>{static_cast<
index_type>(std::move(exts))...}[.](#5.sentence-1)
[6](#6)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L21327)
*Constraints*:
- [(6.1)](#6.1)
(is_convertible_v<OtherIndexTypes, index_type> && ...) is true,
- [(6.2)](#6.2)
(is_nothrow_constructible_v<index_type, OtherIndexTypes> && ...) is true, and
- [(6.3)](#6.3)
N == rank_dynamic() || N == rank() is true[.](#6.sentence-1)
[*Note [1](#note-1)*:
One can construct extents from just dynamic extents,
which are all the values getting stored, or
from all the extents with a precondition[.](#6.3.sentence-2)
— *end note*]
[7](#7)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L21343)
*Preconditions*:
- [(7.1)](#7.1)
If N != rank_dynamic() is true,exts_arr[r] equals Er for each r for which Er is a static extent, and
- [(7.2)](#7.2)
either
* [(7.2.1)](#7.2.1)
sizeof...(exts) == 0 is true, or
* [(7.2.2)](#7.2.2)
each element of exts is representable
as a nonnegative value of type index_type[.](#7.sentence-1)
[8](#8)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L21361)
*Postconditions*: *this == extents(exts_arr) is true[.](#8.sentence-1)
[🔗](#lib:extents,constructor__)
`template<class OtherIndexType, size_t N>
constexpr explicit(N != rank_dynamic())
extents(span<OtherIndexType, N> exts) noexcept;
template<class OtherIndexType, size_t N>
constexpr explicit(N != rank_dynamic())
extents(const array<OtherIndexType, N>& exts) noexcept;
`
[9](#9)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L21377)
*Constraints*:
- [(9.1)](#9.1)
is_convertible_v<const OtherIndexType&, index_type> is true,
- [(9.2)](#9.2)
is_nothrow_constructible_v<index_type, const OtherIndexType&> is true, and
- [(9.3)](#9.3)
N == rank_dynamic() || N == rank() is true[.](#9.sentence-1)
[10](#10)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L21388)
*Preconditions*:
- [(10.1)](#10.1)
If N != rank_dynamic() is true,exts[r] equals Er for each r for which Er is a static extent, and
- [(10.2)](#10.2)
either
* [(10.2.1)](#10.2.1)
N is zero, or
* [(10.2.2)](#10.2.2)
exts[r] is representable
as a nonnegative value of type index_type for every rank index r[.](#10.sentence-1)
[11](#11)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L21405)
*Effects*:
- [(11.1)](#11.1)
If N equals rank_dynamic(),
for all d in the range [0, rank_dynamic()),
direct-non-list-initializes *dynamic-extents*[d] with as_const(exts[d])[.](#11.1.sentence-1)
- [(11.2)](#11.2)
Otherwise, for all d in the range [0, rank_dynamic()),
direct-non-list-initializes *dynamic-extents*[d] with as_const(exts[*dynamic-index-inv*(d)])[.](#11.2.sentence-1)
[🔗](#lib:extents,constructor___)
`template<class... Integrals>
explicit extents(Integrals...) -> see below;
`
[12](#12)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L21427)
*Constraints*: (is_convertible_v<Integrals, size_t> && ...) is true[.](#12.sentence-1)
[13](#13)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L21431)
*Remarks*: The deduced type is extents<size_t, [*maybe-static-ext*](span.syn#concept:maybe-static-ext "23.7.2.1Header <span> synopsis[span.syn]")<Integrals>...>[.](#13.sentence-1)