On this page
std::mdspan<T,Extents,LayoutPolicy,AccessorPolicy>::mdspan
|
(1) | (since C++23) |
|
(2) | (since C++23) |
|
(3) | (since C++23) |
|
(4) | (since C++23) |
|
(5) | (since C++23) |
|
(6) | (since C++23) |
|
(7) | (since C++23) |
|
(8) | (since C++23) |
|
(9) | (since C++23) |
|
(10) | (since C++23) |
Construct 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.
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() > 0istrue,std::is_default_constructible_v<data_handle_type>istrue,std::is_default_constructible_v<mapping_type>istrue, andstd::is_default_constructible_v<accessor_type>istrue.
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> && ...)istrue,(std::is_nothrow_constructible<index_type, OtherIndexTypes> && ...)istrue,N == rank() || N == rank_dynamic()istrue,std::is_constructible_v<mapping_type, extents_type>istrue, andstd::is_default_constructible_v<accessor_type>istrue.
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>istrue,std::is_nothrow_constructible<index_type, const OtherIndexTypes&>istrue,N == rank() || N == rank_dynamic()istrue,std::is_constructible_v<mapping_type, extents_type>istrue, andstd::is_default_constructible_v<accessor_type>istrue.
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&>istrue, andstd::is_default_constructible_v<accessor_type>istrue.
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>istrue.
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.
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_extentis
|| extents_type::static_extent(r) == other.extent(r)false. - This overload participates in overload resolution only if
std::is_constructible_v<mapping_type, const OtherLayoutPolicy::is
template mapping<OtherExtents>&>true, andstd::is_constructible_v<accessor_type, const OtherAccessor&>istrue.- The program is ill-formed if:
std::is_constructible_v<data_handle_type,is
const OtherAccessor::data_handle_type&>false, orstd::is_constructible_v<extents_type, OtherExtents>isfalse.- The expression inside explicit is equivalent to:
!std::is_convertible_v<const OtherLayoutPolicy::
template mapping<OtherExtents>&, mapping_type>
|| !std::is_convertible_v<const OtherAccessor&, accessor_type>
Parameters
| p | - | a handle to the underlying data |
| m | - | a layout mapping |
| a | - | an accessor |
| ext | - | a std::extents object |
| exts | - | represents a multi-dimensional extents |
| other | - | another mdspan to convert from |
| rhs | - | another mdspan to copy or move from |
Example
References
- C++23 standard (ISO/IEC 14882:2023):
- 24.7.3.6.2 Constructors [mdspan.mdspan.cons]
See also
© cppreference.com
Licensed under the Creative Commons Attribution-ShareAlike Unported License v3.0.
https://en.cppreference.com/w/cpp/container/mdspan/mdspan