std::mdspan<T,Extents,LayoutPolicy,AccessorPolicy>::mdspan
constexpr mdspan(); |
(1) | (since C++23) |
template< class... OtherIndexTypes > constexpr explicit mdspan( data_handle_type p, OtherIndexTypes... exts ); |
(2) | (since C++23) |
template< class OtherIndexType, std::size_t N > constexpr explicit(N != rank_dynamic()) |
(3) | (since C++23) |
template< class OtherIndexType, std::size_t N > constexpr explicit(N != rank_dynamic()) |
(4) | (since C++23) |
constexpr mdspan( data_handle_type p, const extents_type& ext ); |
(5) | (since C++23) |
constexpr mdspan( data_handle_type p, const mapping_type& m ); |
(6) | (since C++23) |
constexpr mdspan( data_handle_type p, const mapping_type& m, const accessor_type& a ); |
(7) | (since C++23) |
template< class OtherElementType, class OtherExtents, class OtherLayoutPolicy, class OtherAccessor > |
(8) | (since C++23) |
constexpr mdspan( const mdspan& rhs ) = default; |
(9) | (since C++23) |
constexpr mdspan( mdspan&& rhs ) = default; |
(10) | (since C++23) |
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.
Contents |
[edit] 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 |
[edit] Effects
For the data members listed in the table below:
- If the corresponding initializer is empty, the data member is value-initialized.
- If the corresponding intiializer is not empty, the data member is direct-non-list-initialized with that initializer.
| Overload | Initializer for... | ||
|---|---|---|---|
ptr_
|
map_
|
acc_
| |
| (1) | (empty) | ||
| (2) | std::move(p) | extents_type (static_cast<index_type> (std::move(exts))...) |
(empty) |
| (3) | extents_type(exts) | ||
| (4) | |||
| (5) | ext | ||
| (6) | m | ||
| (7) | a | ||
| (8) | other.ptr_
|
other.map_
|
other.acc_
|
[edit] Constraints and supplement information
- rank_dynamic() > 0
- std::is_default_constructible_v<data_handle_type>
- std::is_default_constructible_v<mapping_type>
- std::is_default_constructible_v<accessor_type>
[0, map_ .required_span_size()) is not an accessible range of ptr_ and acc_ for the values of map_ and acc_ after the invocation of this constructor, the behavior is undefined.- (std::is_convertible_v<OtherIndexTypes, index_type> && ...)
- (std::is_nothrow_constructible<index_type, OtherIndexTypes> && ...)
- sizeof...(OtherIndexTypes) == rank() || sizeof...(OtherIndexTypes) == rank_dynamic()
- std::is_constructible_v<mapping_type, extents_type>
- std::is_default_constructible_v<accessor_type>
[0, map_ .required_span_size()) is not an accessible range of p and acc_ for the values of map_ and acc_ after the invocation of these constructors, the behavior is undefined.- std::is_convertible_v<const OtherIndexType&, index_type>
- std::is_nothrow_constructible_v<index_type, const OtherIndexType&>
- N == rank() || N == rank_dynamic()
- std::is_constructible_v<mapping_type, extents_type>
- std::is_default_constructible_v<accessor_type>
[0, map_ .required_span_size()) is not an accessible range of p and acc_ for the values of map_ and acc_ after the invocation of these constructors, the behavior is undefined.- std::is_constructible_v<mapping_type, const extents_type&>
- std::is_default_constructible_v<accessor_type>
[0, map_ .required_span_size()) is not an accessible range of p and acc_ for the values of map_ and acc_ after the invocation of these constructors, the behavior is undefined.[0, m.required_span_size()) is an accessible range of p and acc_ for the value of acc_ after the invocation of this constructor, the behavior is undefined.[0, m.required_span_size()) is not an accessible range of p and a, the behavior is undefined.mapping_type>
|| !std::is_convertible_v<const OtherAccessor&, accessor_type>.
- std::is_constructible_v
<mapping_type, const OtherLayoutPolicy::template mapping<OtherExtents>&> - std::is_default_constructible_v<accessor_type>
- std::is_constructible_v<data_handle_type, const OtherAccessor::data_handle_type&>
- std::is_constructible_v<extents_type, OtherExtents>
[0, map_ .required_span_size()) is not an accessible range of ptr_ and acc_ for the values of ptr_, map_ and acc_ after the invocation of this constructor, the behavior is undefined.|
If static_extent(r) == std::dynamic_extent |
(until C++26) |
|
If static_extent(r) == std::dynamic_extent
|
(since C++26) |
[edit] Example
| This section is incomplete Reason: no example |
[edit] References
- C++23 standard (ISO/IEC 14882:2024):
- 24.7.3.6.2 Constructors [mdspan.mdspan.cons]
[edit] See also
| This section is incomplete |