![]() |
Arene Base
Fundamental Utilities For Safety Critical C++
|
A multidimensional view of elements over a contiguous sequence of elements. More...

Public Types | |
| using | accessor_type = AccessorPolicy |
| The accessor policy type. | |
| using | data_handle_type = typename accessor_type::data_handle_type |
| The data handle type. | |
| using | element_type = ElementType |
| The element type. | |
| using | extents_type = Extents |
| The extents type. | |
| using | index_type = typename extents_type::index_type |
| The index type. | |
| using | layout_type = LayoutPolicy |
| The layout policy type. | |
| using | mapping_type = typename layout_type::template mapping<extents_type> |
| The mapping type. | |
| using | rank_type = typename extents_type::rank_type |
| The rank type. | |
| using | reference = typename accessor_type::reference |
| The reference type. | |
| using | size_type = typename extents_type::size_type |
| The size type. | |
| using | value_type = std::remove_cv_t<element_type> |
| The value type. | |
Public Member Functions | |
| template<typename Ext = Extents, typename Map = mapping_type, typename Acc = AccessorPolicy, constraints< std::enable_if_t<(Ext::rank_dynamic() > 0)>, std::enable_if_t< std::is_default_constructible< typename Acc::data_handle_type >::value >, std::enable_if_t< std::is_default_constructible< Map >::value >, std::enable_if_t< std::is_default_constructible< Acc >::value >> | |
| constexpr | mdspan () noexcept |
| Default constructor. | |
| template<class OtherIndexType, typename Ext = Extents, typename Map = mapping_type, typename Acc = AccessorPolicy, constraints< std::enable_if_t< std::is_convertible< OtherIndexType const &, index_type >::value >, std::enable_if_t< std::is_nothrow_constructible< index_type, OtherIndexType const & >::value >, std::enable_if_t< std::is_constructible< Map, Ext >::value >, std::enable_if_t< std::is_default_constructible< Acc >::value > > = nullptr> | |
| constexpr | mdspan (data_handle_type handle, array< OtherIndexType, rank_dynamic()> const &extents_in) noexcept |
| Construct mdspan with a data handle and extents. | |
| template<class OtherIndexType, std::size_t Size, typename Ext = Extents, typename Map = mapping_type, typename Acc = AccessorPolicy, constraints< std::enable_if_t< std::is_convertible< OtherIndexType const &, index_type >::value >, std::enable_if_t< std::is_nothrow_constructible< index_type, OtherIndexType const & >::value >, std::enable_if_t< Size==rank()>, std::enable_if_t< Size !=rank_dynamic()>, std::enable_if_t< std::is_constructible< Map, Ext >::value >, std::enable_if_t< std::is_default_constructible< Acc >::value > > = nullptr> | |
| constexpr | mdspan (data_handle_type handle, array< OtherIndexType, Size > const &extents_in) noexcept |
| Construct mdspan with a data handle and extents. | |
| template<typename Ext = Extents, typename Map = mapping_type, typename Acc = AccessorPolicy, constraints< std::enable_if_t< std::is_constructible< Map, Ext const & >::value >, std::enable_if_t< std::is_default_constructible< Acc >::value > > = nullptr> | |
| constexpr | mdspan (data_handle_type handle, extents_type const &extents_in) noexcept |
| Construct mdspan with a data handle and extents. | |
| template<typename Acc = AccessorPolicy, constraints< std::enable_if_t< std::is_default_constructible< Acc >::value > > = nullptr> | |
| constexpr | mdspan (data_handle_type handle, mapping_type const &mapping_in) noexcept |
| Construct mdspan with a data handle and mapping. | |
| constexpr | mdspan (data_handle_type handle, mapping_type const &mapping_in, accessor_type const &accessor_in) noexcept |
| Construct mdspan with a data handle, mapping, and accessor. | |
| template<class... OtherIndexTypes, typename Ext = Extents, typename Map = mapping_type, typename Acc = AccessorPolicy, constraints< std::enable_if_t< all_of_v< std::is_convertible< OtherIndexTypes, index_type >::value... > >, std::enable_if_t< all_of_v< std::is_nothrow_constructible< index_type, OtherIndexTypes >::value... > >, std::enable_if_t< sizeof...(OtherIndexTypes)==rank()||sizeof...(OtherIndexTypes)==rank_dynamic()>, std::enable_if_t< std::is_constructible< Map, Ext >::value >, std::enable_if_t< std::is_default_constructible< Acc >::value > > = nullptr> | |
| constexpr | mdspan (data_handle_type handle, OtherIndexTypes... extents_in) noexcept |
| Construct mdspan with a data handle and extents. | |
| template<class OtherIndexType, typename Ext = Extents, typename Map = mapping_type, typename Acc = AccessorPolicy, constraints< std::enable_if_t< std::is_convertible< OtherIndexType const &, index_type >::value >, std::enable_if_t< std::is_nothrow_constructible< index_type, OtherIndexType const & >::value >, std::enable_if_t< std::is_constructible< Map, Ext >::value >, std::enable_if_t< std::is_default_constructible< Acc >::value > > = nullptr> | |
| constexpr | mdspan (data_handle_type handle, span< OtherIndexType, rank_dynamic()> extents_in) noexcept |
| Construct mdspan with a data handle and extents. | |
| template<class OtherIndexType, std::size_t Size, typename Ext = Extents, typename Map = mapping_type, typename Acc = AccessorPolicy, constraints< std::enable_if_t< std::is_convertible< OtherIndexType const &, index_type >::value >, std::enable_if_t< std::is_nothrow_constructible< index_type, OtherIndexType const & >::value >, std::enable_if_t< Size==rank()>, std::enable_if_t< Size !=rank_dynamic()>, std::enable_if_t< std::is_constructible< Map, Ext >::value >, std::enable_if_t< std::is_default_constructible< Acc >::value > > = nullptr> | |
| constexpr | mdspan (data_handle_type handle, span< OtherIndexType, Size > extents_in) noexcept |
| Construct mdspan with a data handle and extents. | |
| template<class OtherElementType, class OtherExtents, class OtherLayoutPolicy, class OtherAccessor, constraints< std::enable_if_t< converting_constructor_is_explicit_v< OtherExtents, OtherLayoutPolicy, OtherAccessor > >, std::enable_if_t< std::is_constructible< mapping_type, typename OtherLayoutPolicy::template mapping< OtherExtents > const & >::value >, std::enable_if_t< std::is_constructible< accessor_type, OtherAccessor const & >::value >, std::enable_if_t< std::is_constructible< data_handle_type, typename OtherAccessor::data_handle_type const & >::value >, std::enable_if_t< std::is_constructible< extents_type, OtherExtents const & >::value > > = nullptr> | |
| constexpr | mdspan (mdspan< OtherElementType, OtherExtents, OtherLayoutPolicy, OtherAccessor > const &other) |
Converting constructor from another mdspan. | |
| template<class OtherElementType, class OtherExtents, class OtherLayoutPolicy, class OtherAccessor, constraints< std::enable_if_t<!converting_constructor_is_explicit_v< OtherExtents, OtherLayoutPolicy, OtherAccessor > >, std::enable_if_t< std::is_constructible< mapping_type, typename OtherLayoutPolicy::template mapping< OtherExtents > const & >::value >, std::enable_if_t< std::is_constructible< accessor_type, OtherAccessor const & >::value >, std::enable_if_t< std::is_constructible< data_handle_type, typename OtherAccessor::data_handle_type const & >::value >, std::enable_if_t< std::is_constructible< extents_type, OtherExtents const & >::value > > = nullptr> | |
| constexpr | mdspan (mdspan< OtherElementType, OtherExtents, OtherLayoutPolicy, OtherAccessor > const &other) |
Converting constructor from another mdspan. | |
| constexpr auto | accessor () const noexcept -> accessor_type const & |
| Get the accessor. | |
| constexpr auto | data_handle () const noexcept -> data_handle_type const & |
| Get the data handle. | |
| constexpr auto | empty () const noexcept -> bool |
| Check if the size is zero. | |
| constexpr auto | extent (rank_type dimension) const noexcept -> index_type |
| Get the actual extent for the given dimension, returning the extent supplied to the constructor for dynamic extents. | |
| constexpr auto | mapping () const noexcept -> mapping_type const & |
| Get the mapping. | |
| template<class OtherIndexType, constraints< std::enable_if_t< std::is_convertible< OtherIndexType const &, index_type >::value >, std::enable_if_t< std::is_nothrow_constructible< index_type, OtherIndexType const & >::value > > = nullptr> | |
| constexpr auto | operator() (array< OtherIndexType, extents_type::rank > const &indices) const noexcept(arene::base::is_nothrow_invocable_v<, mdspan const &, array< OtherIndexType, extents_type::rank()> const & >) -> reference |
Access an element with an array of indices. | |
| template<class... OtherIndexTypes, constraints< std::enable_if_t< std::is_convertible< OtherIndexTypes, index_type >::value >..., std::enable_if_t< std::is_nothrow_constructible< index_type, OtherIndexTypes >::value >..., std::enable_if_t< sizeof...(OtherIndexTypes)==extents_type::rank > > = nullptr> | |
| constexpr auto | operator() (OtherIndexTypes... indices) const noexcept(arene::base::is_nothrow_invocable_v< mapping_type const &, OtherIndexTypes &&... > &&noexcept(std::declval< accessor_type const & >().access(//std::declval< data_handle_type const & >(),//std::declval< std::size_t >()))) -> reference |
| Access an element at the specified multi-dimensional index. | |
| template<class OtherIndexType, constraints< std::enable_if_t< std::is_convertible< OtherIndexType const &, index_type >::value >, std::enable_if_t< std::is_nothrow_constructible< index_type, OtherIndexType const & >::value > > = nullptr> | |
| constexpr auto | operator() (span< OtherIndexType, extents_type::rank > const indices) const noexcept(arene::base::is_nothrow_invocable_v<, mdspan const &, mdspan_detail::tuple_span< OtherIndexType, extents_type::rank > const & >) -> reference |
Access an mdspan element with a span of indices. | |
| constexpr auto | size () const noexcept -> size_type |
| Get the size of the multidimensional index space. | |
Static Public Member Functions | |
| static constexpr auto | static_extent (rank_type dimension) noexcept -> std::size_t |
| Get the static extent for the given dimension. | |
Static Public Attributes | |
| static constexpr std::integral_constant< rank_type, Extents::rank()> | rank {} |
| Get the number of dimensions. | |
| static constexpr std::integral_constant< rank_type, Extents::rank_dynamic()> | rank_dynamic {} |
| Get the number of dimensions with dynamic extent. | |
Friends | |
| constexpr auto | swap (mdspan &lhs, mdspan &rhs) noexcept -> void |
| swaps the contents | |
A multidimensional view of elements over a contiguous sequence of elements.
| ElementType | the element type |
| Extents | an instantiation of extents representing the shape of the multidimensional index space |
| LayoutPolicy | a layout policy (defaults to layout_right) |
| AccessorPolicy | an accessor policy (defaults to default_accessor<ElementType>) |
Backport of std::mdspan from C++23. The mdspan class template is a multidimensional array view that maps a multidimensional index to an element of the array. The mapping and element access policies are configurable, and the underlying array need not be contiguous or even exist in memory at all.
| using arene::base::mdspan< ElementType, Extents, LayoutPolicy, AccessorPolicy >::accessor_type = AccessorPolicy |
The accessor policy type.
| using arene::base::mdspan< ElementType, Extents, LayoutPolicy, AccessorPolicy >::data_handle_type = typename accessor_type::data_handle_type |
The data handle type.
| using arene::base::mdspan< ElementType, Extents, LayoutPolicy, AccessorPolicy >::element_type = ElementType |
The element type.
| using arene::base::mdspan< ElementType, Extents, LayoutPolicy, AccessorPolicy >::extents_type = Extents |
The extents type.
| using arene::base::mdspan< ElementType, Extents, LayoutPolicy, AccessorPolicy >::index_type = typename extents_type::index_type |
The index type.
| using arene::base::mdspan< ElementType, Extents, LayoutPolicy, AccessorPolicy >::layout_type = LayoutPolicy |
The layout policy type.
| using arene::base::mdspan< ElementType, Extents, LayoutPolicy, AccessorPolicy >::mapping_type = typename layout_type::template mapping<extents_type> |
The mapping type.
| using arene::base::mdspan< ElementType, Extents, LayoutPolicy, AccessorPolicy >::rank_type = typename extents_type::rank_type |
The rank type.
| using arene::base::mdspan< ElementType, Extents, LayoutPolicy, AccessorPolicy >::reference = typename accessor_type::reference |
The reference type.
| using arene::base::mdspan< ElementType, Extents, LayoutPolicy, AccessorPolicy >::size_type = typename extents_type::size_type |
The size type.
| using arene::base::mdspan< ElementType, Extents, LayoutPolicy, AccessorPolicy >::value_type = std::remove_cv_t<element_type> |
The value type.
|
inlineconstexprnoexcept |
Default constructor.
[0, mapping().required_span_size()) is an accessible range of data_handle() and accessor() for the values of mapping() and accessor() after the invocation of this constructor. This precondition is not checked, but violating it is undefined behavior.
|
inlineexplicitconstexprnoexcept |
Construct mdspan with a data handle and extents.
| OtherIndexTypes | The types of the extents used to initialize the layout mapping |
| handle | A user supplied data handle |
| extents_in | User supplied extents |
Construct an mdspan initialized with a user supplied data_handle_type, a variadic list of extents which are converted to extents_type and used to initialize the layout mapping, and a default constructed accessor_type.
[0, mapping().required_span_size()) is an accessible range of handle and accessor() for the values of mapping() and accessor() after the invocation of this constructor. This precondition is not checked, but violating it is undefined behavior.
|
inlineexplicitconstexprnoexcept |
Construct mdspan with a data handle and extents.
| OtherIndexType | The type of the extent values used to initialize the layout mapping |
| handle | A user supplied data handle |
| extents_in | User supplied extents |
Construct an mdspan initialized with a user supplied data_handle_type, a span of extents which are converted to extents_type and used to initialize the layout mapping, and a default constructed accessor_type.
[0, mapping().required_span_size()) is an accessible range of handle and accessor() for the values of mapping() and accessor() after the invocation of this constructor. This precondition is not checked, but violating it is undefined behavior.explicit only if N != rank_dynamic() .
|
inlineconstexprnoexcept |
Construct mdspan with a data handle and extents.
| OtherIndexType | The type of the extent values used to initialize the layout mapping |
| handle | A user supplied data handle |
| extents_in | User supplied extents |
Construct an mdspan initialized with a user supplied data_handle_type, a span of extents which are converted to extents_type and used to initialize the layout mapping, and a default constructed accessor_type.
[0, mapping().required_span_size()) is an accessible range of handle and accessor() for the values of mapping() and accessor after the invocation of this constructor. This precondition is not checked, but violating it is undefined behavior.explicit only if N != rank_dynamic() .
|
inlineexplicitconstexprnoexcept |
Construct mdspan with a data handle and extents.
| OtherIndexType | The type of the extent values used to initialize the layout mapping |
| handle | A user supplied data handle |
| extents_in | User supplied extents |
Construct an mdspan initialized with a user supplied data_handle_type, an array of extents which are converted to extents_type and used to initialize the layout mapping, and a default constructed accessor_type.
[0, mapping().required_span_size()) is an accessible range of handle and accessor() for the values of mapping() and accessor after the invocation of this constructor. This precondition is not checked, but violating it is undefined behavior.explicit only if N != rank_dynamic() .
|
inlineconstexprnoexcept |
Construct mdspan with a data handle and extents.
| OtherIndexType | The type of the extent values used to initialize the layout mapping |
| handle | A user supplied data handle |
| extents_in | User supplied extents |
Construct an mdspan initialized with a user supplied data_handle_type, an array of extents which are converted to extents_type and used to initialize the layout mapping, and a default constructed accessor_type.
[0, mapping().required_span_size()) is an accessible range of handle and accessor() for the values of mapping() and accessor after the invocation of this constructor. This precondition is not checked, but violating it is undefined behavior.explicit only if N != rank_dynamic() .
|
inlineconstexprnoexcept |
Construct mdspan with a data handle and extents.
| handle | A user supplied data handle |
| extents_in | User supplied extents |
[0, mapping().required_span_size()) is an accessible range of handle and accessor() for the values of mapping() and accessor() after the invocation of this constructor. This precondition is not checked, but violating it is undefined behavior.Construct an mdspan initialized with a user supplied data_handle_type, a user supplied extents_type used to initialize the layout mapping, and a default constructed accessor_type.
|
inlineconstexprnoexcept |
Construct mdspan with a data handle and mapping.
| handle | A user supplied data handle |
| mapping_in | User supplied mapping |
[0, mapping_in.required_span_size()) is an accessible range of handle and accessor() for the value of accessor() after the invocation of this constructor. This precondition is not checked, but violating it is undefined behavior.Construct an mdspan initialized with a user supplied data_handle_type, a user supplied mapping, and a default constructed accessor_type.
|
inlineconstexprnoexcept |
Construct mdspan with a data handle, mapping, and accessor.
| handle | A user supplied data handle |
| mapping_in | User supplied mapping |
| accessor_in | User supplied accessor |
[0, mapping_in.required_span_size()) is an accessible range of handle and accessor_in. This precondition is not checked, but violating it is undefined behavior.Construct an mdspan initialized with a user supplied data_handle_type, a user supplied mapping, and a user supplied accessor_type.
|
inlineexplicitconstexpr |
Converting constructor from another mdspan.
| OtherElementType | The element type of the other mdspan |
| OtherExtents | The extents type of the other mdspan |
| OtherLayoutPolicy | The layout policy of the other mdspan |
| OtherAccessor | The accessor policy of the other mdspan |
| other | The other mdspan to construct from |
r of extents_type, static_extent(r) == dynamic_extent || static_extent(r) == other.extent(r) is true, otherwise this is an ARENE_PRECONDITION violation. [0, mapping().required_span_size()) is an accessible range of handle() and accessor() for values of handle(), mapping(), and accessor() after the invocation of this constructor. This precondition is not checked, but violating it is undefined behavior.explicit only if !std::is_convertible<typename OtherLayoutPolicy::template mapping<OtherExtents> const&, mapping_type>::value || !std::is_convertible<OtherAccessor const&, accessor_type>::value;
|
inlineconstexpr |
Converting constructor from another mdspan.
| OtherElementType | The element type of the other mdspan |
| OtherExtents | The extents type of the other mdspan |
| OtherLayoutPolicy | The layout policy of the other mdspan |
| OtherAccessor | The accessor policy of the other mdspan |
| other | The other mdspan to construct from |
r of extents_type, static_extent(r) == dynamic_extent || static_extent(r) == other.extent(r) is true, otherwise this is an ARENE_PRECONDITION violation. [0, mapping().required_span_size()) is an accessible range of handle() and accessor() for values of handle(), mapping(), and accessor() after the invocation of this constructor. This precondition is not checked, but violating it is undefined behavior.explicit only if !std::is_convertible<typename OtherLayoutPolicy::template mapping<OtherExtents> const&, mapping_type>::value || !std::is_convertible<OtherAccessor const&, accessor_type>::value;
|
inlineconstexprnoexcept |
Get the accessor.
|
inlineconstexprnoexcept |
Get the data handle.
|
inlineconstexprnoexcept |
Check if the size is zero.
true if the size is zero, false otherwise
|
inlineconstexprnoexcept |
Get the actual extent for the given dimension, returning the extent supplied to the constructor for dynamic extents.
| dimension | The index of the dimension for which to get the extent |
|
inlineconstexprnoexcept |
Get the mapping.
|
inlineconstexprnoexcept |
Access an element with an array of indices.
| OtherIndexType | Index type contained by the array |
| indices | The multi-dimensional index as an array |
|
inlineconstexprnoexcept |
Access an element at the specified multi-dimensional index.
| OtherIndexTypes | Non-type template parameter pack of indices |
| indices | The multi-dimensional index as a variadic |
|
inlineconstexprnoexcept |
Access an mdspan element with a span of indices.
| OtherIndexType | Index type contained by the span |
| indices | The multi-dimensional index as an span |
|
inlineconstexprnoexcept |
Get the size of the multidimensional index space.
|
inlinestaticconstexprnoexcept |
Get the static extent for the given dimension.
| dimension | The index of the dimension for which to get the static extent |
Extents for the specified dimension
|
friend |
swaps the contents
| lhs | left mdspan value to swap |
| rhs | right mdspan value to swap |
|
staticconstexpr |
Get the number of dimensions.
|
staticconstexpr |
Get the number of dimensions with dynamic extent.