std::mdspan::mdspan(3)
π NAME π
okay bestie, this is the page for std::mdspan::mdspan from the C++ Standard Libary manual β yes, that's how it's spelled here, and yes, the page title is exactly std::mdspan::mdspan(3) π
The name line is literally:
std::mdspan::mdspan - std::mdspan::mdspan
self-referential icon behavior, we love to see it β¨
β¨ Synopsis β¨
These are all ten constructor overloads, and every single one is since C++23 because we're fancy like that π«Ά
(1) β since C++23
constexpr mdspan();
(2) β since C++23
template< class... OtherIndexTypes >
constexpr explicit mdspan( data_handle_type p, OtherIndexTypes... exts );
(3) β since C++23
template< class OtherIndexType, std::size_t N >
constexpr explicit(N != rank_dynamic())
mdspan( data_handle_type p, std::span<OtherIndexType, N> exts );
(4) β since C++23
template< class OtherIndexType, std::size_t N >
constexpr explicit(N != rank_dynamic())
mdspan( data_handle_type p, const std::array<OtherIndexType, N>& exts );
(5) β since C++23
constexpr mdspan( data_handle_type p, const extents_type& ext );
(6) β since C++23
constexpr mdspan( data_handle_type p, const mapping_type& m );
(7) β since C++23
constexpr mdspan( data_handle_type p, const mapping_type& m,
const accessor_type& a );
(8) β since C++23
template< class OtherElementType, class OtherExtents,
class OtherLayoutPolicy, class OtherAccessor >
constexpr explicit(/* see below */)
mdspan( const mdspan<OtherElementType, OtherExtents,
OtherLayoutPolicy, OtherAccessor>& other );
(9) β since C++23
constexpr mdspan( const mdspan& rhs ) = default;
(10) β since C++23
constexpr mdspan( mdspan&& rhs ) = default;
okay so here's the actual construction tea β
Constructs an mdspan, optionally using user-supplied data handle p, layout mapping m, and accessor a. If extents exts or ext are supplied, they are converted to extents_type and used to initialize the layout mapping. periodt.
(1)
Constructs an empty mdspan. Value-initializes ptr_, map_, and acc_.
- The behavior is undefined if
[0, map_.required_span_size())is not an accessible range ofptr_andacc_for the values ofmap_andacc_after the invocation of this constructor. - This overload participates in overload resolution only if
rank_dynamic() > 0is true,std::is_default_constructible_v<data_handle_type>is true,std::is_default_constructible_v<mapping_type>is true, andstd::is_default_constructible_v<accessor_type>is true.
(2)
Constructs an mdspan over the underlying data referred by p with extents represented by exts.... Value-initializes acc_, direct-non-list-initializes ptr_ with std::move(p) and map_ with extents_type(static_cast<index_type>(std::move(exts))...).
- The behavior is undefined if
[0, map_.required_span_size())is not an accessible range ofptr_andacc_for the values ofmap_andacc_after the invocation of this constructor. - Let
Nbesizeof...(OtherIndexTypes). This overload participates in overload resolution only if(std::is_convertible_v<OtherIndexTypes, index_type> && ...)is true,(std::is_nothrow_constructible<index_type, OtherIndexTypes> && ...)is true,N == rank() || N == rank_dynamic()is true,std::is_constructible_v<mapping_type, extents_type>is true, andstd::is_default_constructible_v<accessor_type>is true.
(3,4)
Constructs an mdspan over the underlying data referred by p with extents represented by pack exts. Value-initializes acc_, direct-non-list-initializes ptr_ with std::move(p) and map_ with extents_type(exts).
- The behavior is undefined if
[0, map_.required_span_size())is not an accessible range ofptr_andacc_for the values ofmap_andacc_after the invocation of this constructor. - This overload participates in overload resolution only if
std::is_convertible_v<const OtherIndexTypes&, index_type>is true,std::is_nothrow_constructible<index_type, const OtherIndexTypes&>is true,N == rank() || N == rank_dynamic()is true,std::is_constructible_v<mapping_type, extents_type>is true, andstd::is_default_constructible_v<accessor_type>is true.
(5)
Constructs an mdspan over the underlying data referred by p with extents represented by ext. Value-initializes acc_, direct-non-list-initializes ptr_ with std::move(p) and map_ with exts.
- The behavior is undefined if
[0, map_.required_span_size())is not an accessible range ofpandacc_for the values ofmap_andacc_after the invocation of this constructor. - This overload participates in overload resolution only if
std::is_constructible_v<mapping_type, const mapping_type&>is true, andstd::is_default_constructible_v<accessor_type>is true.
(6)
Constructs an mdspan over the underlying data referred by p with layout mapping m. Value-initializes acc_, direct-non-list-initializes ptr_ with std::move(p) and map_ with m.
- The behavior is undefined if
[0, m.required_span_size())is not an accessible range ofpandacc_for the values ofacc_after the invocation of this constructor. - This overload participates in overload resolution only if
std::is_default_constructible_v<accessor_type>is true.
(7)
Constructs an mdspan over the underlying data referred by p with layout mapping m and accessor a. Direct-non-list-initializes ptr_ with std::move(p), map_ with m and acc_ with a.
- The behavior is undefined if
[0, m.required_span_size())is not an accessible range ofpandaafter the invocation of this constructor.
(8)
Converting constructor from another mdspan. Direct-non-list-initializes ptr_ with other.ptr_, map_ with other.map_ and acc_ with other.acc_.
- The behavior is undefined if:
[0, map_.required_span_size())is not an accessible range ofptr_andacc_for the values ofmap_andacc_after the invocation of this constructor, or- for each rank index
rofextents_type,extents_type::static_extent(r) == std::dynamic_extent || extents_type::static_extent(r) == other.extent(r)is false.
- This overload participates in overload resolution only if
std::is_constructible_v<mapping_type, const OtherLayoutPolicy::template mapping<OtherExtents>&>is true, andstd::is_constructible_v<accessor_type, const OtherAccessor&>is true.
- The program is ill-formed if:
std::is_constructible_v<data_handle_type, const OtherAccessor::data_handle_type&>is false, orstd::is_constructible_v<extents_type, OtherExtents>is false.
- The expression inside
explicitis equivalent to:
!std::is_convertible_v<const OtherLayoutPolicy::
template mapping<OtherExtents>&, mapping_type>
|| !std::is_convertible_v<const OtherAccessor&, accessor_type>
(9)
Defaulted copy constructor.
(10)
Defaulted move constructor.
πΈ Parameters πΈ
pβ a handle to the underlying datamβ a layout mappingaβ an accessorextβ astd::extentsobjectextsβ represents a multi-dimensional extentsotherβ anothermdspanto convert fromrhsβ anothermdspanto copy or move from
π§ Example π§
This section is incomplete
Reason: no example
(no cap, that's literally what it says π)
π₯ References π₯
- C++23 standard (ISO/IEC 14882:2023):
- 24.7.3.6.2 Constructors [mdspan.mdspan.cons]
π¦ See also π¦
This section is incomplete
π Categories π
- Todo no example
- Todo without reason
okay that's the whole constructor saga π source: cppreference.com; version/date: 2024.06.10; page: std::mdspan::mdspan(3) β slay and goodbye bestie π«Άβ¨
π¦ where this page comes from
- nixpkgs unstable: stdman 2024.07.05
- opensuse-leap 16.0: stdman 2024.07.05-bp160.1.9 Β· MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms