23 Containers library [containers]

23.7 Views [views]

23.7.3 Multidimensional access [views.multidim]

23.7.3.6 Class template mdspan [mdspan.mdspan]

23.7.3.6.2 Constructors [mdspan.mdspan.cons]

constexpr mdspan();
Constraints:
  • rank_dynamic() > 0 is true.
  • is_default_constructible_v<data_handle_type> is true.
  • is_default_constructible_v<mapping_type> is true.
  • is_default_constructible_v<accessor_type> is true.
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.
Effects: Value-initializes ptr_, map_, and acc_.
template<class... OtherIndexTypes> constexpr explicit mdspan(data_handle_type p, OtherIndexTypes... exts);
Let N be sizeof...(OtherIndexTypes).
Constraints:
  • (is_convertible_v<OtherIndexTypes, index_type> && ...) is true,
  • (is_nothrow_constructible<index_type, OtherIndexTypes> && ...) is true,
  • N == rank() || N == rank_dynamic() is true,
  • is_constructible_v<mapping_type, extents_type> is true, and
  • is_default_constructible_v<accessor_type> is true.
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.
Effects:
  • Direct-non-list-initializes ptr_ with std​::​move(p),
  • direct-non-list-initializes map_ with extents_type(static_cast<index_type>(std​::​move(exts​))...), and
  • value-initializes acc_.
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);
Constraints:
  • is_convertible_v<const OtherIndexType&, index_type> is true,
  • is_nothrow_constructible_v<index_type, const OtherIndexType&> is true,
  • N == rank() || N == rank_dynamic() is true,
  • is_constructible_v<mapping_type, extents_type> is true, and
  • is_default_constructible_v<accessor_type> is true.
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.
Effects:
  • Direct-non-list-initializes ptr_ with std​::​move(p),
  • direct-non-list-initializes map_ with extents_type(exts), and
  • value-initializes acc_.
constexpr mdspan(data_handle_type p, const extents_type& ext);
Constraints:
  • is_constructible_v<mapping_type, const extents_type&> is true, and
  • is_default_constructible_v<accessor_type> is true.
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.
Effects:
  • Direct-non-list-initializes ptr_ with std​::​move(p),
  • direct-non-list-initializes map_ with ext, and
  • value-initializes acc_.
constexpr mdspan(data_handle_type p, const mapping_type& m);
Constraints: is_default_constructible_v<accessor_type> is true.
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.
Effects:
  • Direct-non-list-initializes ptr_ with std​::​move(p),
  • direct-non-list-initializes map_ with m, and
  • value-initializes acc_.
constexpr mdspan(data_handle_type p, const mapping_type& m, const accessor_type& a);
Preconditions: [0, m.required_span_size()) is an accessible range of p and a.
Effects:
  • Direct-non-list-initializes ptr_ with std​::​move(p),
  • direct-non-list-initializes map_ with m, and
  • direct-non-list-initializes acc_ with a.
template<class OtherElementType, class OtherExtents, class OtherLayoutPolicy, class OtherAccessor> constexpr explicit(see below) mdspan(const mdspan<OtherElementType, OtherExtents, OtherLayoutPolicy, OtherAccessor>& other);
Constraints:
  • is_constructible_v<mapping_type, const OtherLayoutPolicy​::​template mapping<Oth-
    erExtents>&>
    is true, and
  • is_constructible_v<accessor_type, const OtherAccessor&> is true.
Mandates:
  • is_constructible_v<data_handle_type, const OtherAccessor​::​data_handle_type&> is
    true, and
  • is_constructible_v<extents_type, OtherExtents> is true.
Preconditions:
  • For each rank index r of extents_type, static_extent(r) == dynamic_extent || static_extent(r) == other.extent(r) is true.
  • [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.
Effects:
  • Direct-non-list-initializes ptr_ with other.ptr_,
  • direct-non-list-initializes map_ with other.map_, and
  • direct-non-list-initializes acc_ with other.acc_.
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>