24 Containers library [containers]

24.7 Views [views]

24.7.3 Multidimensional access [views.multidim]

24.7.3.3 Class template extents [mdspan.extents]

24.7.3.3.3 Constructors [mdspan.extents.cons]

template<class OtherIndexType, size_t... OtherExtents> constexpr explicit(see below) extents(const extents<OtherIndexType, OtherExtents...>& other) noexcept;
Constraints:
  • sizeof...(OtherExtents) == rank() is true.
  • ((OtherExtents == dynamic_extent || Extents == dynamic_extent || OtherExtents ==
    Extents) && ...)
    is true.
Preconditions:
  • other.extent(r) equals for each r for which is a static extent, and
  • either
    • sizeof...(OtherExtents) is zero, or
    • other.extent(r) is representable as a value of type index_type for every rank index r of other.
Postconditions: *this == other is true.
Remarks: The expression inside explicit is equivalent to: (((Extents != dynamic_extent) && (OtherExtents == dynamic_extent)) || ... ) || (numeric_limits<index_type>::max() < numeric_limits<OtherIndexType>::max())
template<class... OtherIndexTypes> constexpr explicit extents(OtherIndexTypes... exts) noexcept;
Let N be sizeof...(OtherIndexTypes), and let exts_arr be array<index_type, N>{static_cast<
index_type>(std​::​move(exts))...}
.
Constraints:
  • (is_convertible_v<OtherIndexTypes, index_type> && ...) is true,
  • (is_nothrow_constructible_v<index_type, OtherIndexTypes> && ...) is true, and
  • N == rank_dynamic() || N == rank() is true.
    [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.
    — end note]
Preconditions:
  • If N != rank_dynamic() is true, exts_arr[r] equals for each r for which is a static extent, and
  • either
    • sizeof...(exts) == 0 is true, or
    • each element of exts is representable as a nonnegative value of type index_type.
Postconditions: *this == extents(exts_arr) is true.
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;
Constraints:
  • is_convertible_v<const OtherIndexType&, index_type> is true,
  • is_nothrow_constructible_v<index_type, const OtherIndexType&> is true, and
  • N == rank_dynamic() || N == rank() is true.
Preconditions:
  • If N != rank_dynamic() is true, exts[r] equals for each r for which is a static extent, and
  • either
    • N is zero, or
    • exts[r] is representable as a nonnegative value of type index_type for every rank index r.
Effects:
  • If N equals dynamic_rank(), for all d in the range [0, rank_dynamic()), direct-non-list-initializes dynamic-extents[d] with as_const(exts[d]).
  • 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)]).
template<class... Integrals> explicit extents(Integrals...) -> see below;
Constraints: (is_convertible_v<Integrals, size_t> && ...) is true.
Remarks: The deduced type is dextents<size_t, sizeof...(Integrals)>.