3#ifndef TETL_MDSPAN_MDSPAN_HPP
4#define TETL_MDSPAN_MDSPAN_HPP
51 [[nodiscard]]
static constexpr auto rank() noexcept ->
rank_type {
return extents_type::rank(); }
53 [[nodiscard]]
static constexpr auto rank_dynamic() noexcept ->
rank_type {
return extents_type::rank_dynamic(); }
57 return Extents::static_extent(r);
73 template <
typename... OtherIndexTypes>
76 and ((
sizeof...(OtherIndexTypes) ==
rank()) || (
sizeof...(OtherIndexTypes) ==
rank_dynamic()))
85 template <
typename OtherIndexType,
size_t N>
98 template <
typename OtherIndexType,
size_t N>
134 template <
typename OtherElement,
typename OtherExtents,
typename OtherLayout,
typename OtherAccessor>
152 template <
typename... OtherIndexTypes>
156 and sizeof...(OtherIndexTypes) ==
rank()
158 [[nodiscard]] constexpr auto operator()(OtherIndexTypes... indices) const ->
reference
160 auto const idx =
static_cast<etl::size_t>(_map(extents_type::index_cast(
etl::move(indices))...));
161 return _acc.access(_ptr, idx);
164#if defined(__cpp_multidimensional_subscript)
165 template <
typename... OtherIndexTypes>
169 and sizeof...(OtherIndexTypes) ==
rank()
171 [[nodiscard]] constexpr auto operator[](OtherIndexTypes... indices) const ->
reference
177 template <
typename OtherIndexType>
182 return (*
this)(indices[Is]...);
186 template <
typename OtherIndexType>
188 [[nodiscard]]
constexpr auto operator[](
array<OtherIndexType,
rank()>
const& indices)
const ->
reference
205 [[nodiscard]]
constexpr auto is_unique() const ->
bool {
return _map.is_unique(); }
206 [[nodiscard]]
constexpr auto is_exhaustive() const ->
bool {
return _map.is_exhaustive(); }
207 [[nodiscard]]
constexpr auto is_strided() const ->
bool {
return _map.is_strided(); }
209 [[nodiscard]]
static constexpr auto is_always_unique() ->
bool {
return mapping_type::is_always_unique(); }
210 [[nodiscard]]
static constexpr auto is_always_exhaustive() ->
bool {
return mapping_type::is_always_exhaustive(); }
211 [[nodiscard]]
static constexpr auto is_always_strided() ->
bool {
return mapping_type::is_always_strided(); }
219template <
typename CArray>
223template <
typename Po
inter>
227template <
typename ElementType,
typename... Integrals>
231template <
typename ElementType,
typename IndexType,
size_t... ExtentsPack>
235template <
typename ElementType,
typename MappingType>
239template <
typename MappingType,
typename AccessorType>
240mdspan(
typename AccessorType::data_handle_type
const&, MappingType
const&, AccessorType
const&) ->
mdspan<
241 typename AccessorType::element_type,
242 typename MappingType::extents_type,
243 typename MappingType::layout_type,
246template <
typename ElementType,
typename Extents,
typename LayoutPolicy,
typename Container>
249template <
class ElementType,
class Extents,
class Layout,
class Container>
252 typename decltype(
declval<
mdarray<ElementType, Extents, Layout, Container>>().to_mdspan())::extens_type,
253 typename decltype(
declval<
mdarray<ElementType, Extents, Layout, Container>>().to_mdspan())::layout_type,
254 typename decltype(
declval<
mdarray<ElementType, Extents, Layout, Container>>().to_mdspan())::accessor_type>;
#define TETL_NO_UNIQUE_ADDRESS
Definition attributes.hpp:41
constexpr auto move(InputIt first, InputIt last, OutputIt destination) -> OutputIt
Moves the elements in the range [first, last), to another range beginning at destination,...
Definition move.hpp:26
Definition adjacent_find.hpp:8
constexpr bool is_constructible_v
Definition is_constructible.hpp:24
mdspan(CArray &) -> mdspan< remove_all_extents_t< CArray >, extents< size_t, extent_v< CArray, 0 > > >
auto declval() noexcept -> add_rvalue_reference_t< T >
etl::make_integer_sequence< etl::size_t, Size > make_index_sequence
Definition index_sequence.hpp:15
constexpr size_t rank_v
Definition rank.hpp:25
remove_const_t< remove_volatile_t< T > > remove_cv_t
Definition remove_cv.hpp:22
constexpr bool is_default_constructible_v
Definition is_default_constructible.hpp:26
constexpr bool is_pointer_v
Definition is_pointer.hpp:30
etl::integer_sequence< etl::size_t, Ints... > index_sequence
Definition index_sequence.hpp:12
constexpr bool is_array_v
Definition is_array.hpp:26
constexpr bool is_nothrow_constructible_v
Definition is_nothrow_constructible.hpp:50
typename detail::dextents_impl< IndexType, etl::make_index_sequence< Rank > >::type dextents
Definition extents.hpp:196
constexpr bool is_convertible_v
Definition is_convertible.hpp:46
TETL_BUILTIN_SIZET size_t
etl::size_t is the unsigned integer type of the result of the sizeof operator.
Definition size_t.hpp:14
A container that encapsulates fixed size arrays.
Definition array.hpp:48
Definition default_accessor.hpp:12
ElementType & reference
Definition default_accessor.hpp:15
ElementType * data_handle_type
Definition default_accessor.hpp:16
Definition extents.hpp:22
Definition mdarray.hpp:25
static constexpr auto is_always_unique() -> bool
Definition mdspan.hpp:209
typename extents_type::rank_type rank_type
Definition mdspan.hpp:47
constexpr mdspan(data_handle_type ptr, mapping_type const &m)
Definition mdspan.hpp:119
static constexpr auto rank() noexcept -> rank_type
Definition mdspan.hpp:51
constexpr auto accessor() const noexcept -> accessor_type const &
Definition mdspan.hpp:195
typename extents_type::index_type index_type
Definition mdspan.hpp:45
constexpr mdspan(data_handle_type ptr, extents_type const &ext)
Definition mdspan.hpp:111
constexpr auto stride(rank_type r) const -> index_type
Definition mdspan.hpp:198
extents_type extents_type
Definition mdspan.hpp:39
default_accessor< element_type > accessor_type
Definition mdspan.hpp:41
OtherAccessor const & other
Definition mdspan.hpp:142
constexpr mdspan()
Definition mdspan.hpp:63
typename accessor_type::data_handle_type data_handle_type
Definition mdspan.hpp:48
typename accessor_type::reference reference
Definition mdspan.hpp:49
layout_type layout_type
Definition mdspan.hpp:40
constexpr auto mapping() const noexcept -> mapping_type const &
Definition mdspan.hpp:194
element_type element_type
Definition mdspan.hpp:43
constexpr mdspan(data_handle_type ptr, mapping_type const &m, accessor_type const &a)
Definition mdspan.hpp:127
explicit(N !=rank_dynamic()) const expr mdspan(data_handle_type p
constexpr auto extent(rank_type r) const noexcept -> index_type
Definition mdspan.hpp:60
span< OtherIndexType, N > exts
Definition mdspan.hpp:92
constexpr auto empty() const noexcept -> bool
Definition mdspan.hpp:199
typename extents_type::size_type size_type
Definition mdspan.hpp:46
constexpr auto data_handle() const noexcept -> data_handle_type const &
Definition mdspan.hpp:193
constexpr auto operator[](span< OtherIndexType, rank()> indices) const -> reference
Definition mdspan.hpp:179
static constexpr auto rank_dynamic() noexcept -> rank_type
Definition mdspan.hpp:53
static constexpr auto is_always_exhaustive() -> bool
Definition mdspan.hpp:210
constexpr auto is_unique() const -> bool
Definition mdspan.hpp:205
constexpr mdspan(mdspan &&rhs)=default
constexpr auto is_strided() const -> bool
Definition mdspan.hpp:207
constexpr auto is_exhaustive() const -> bool
Definition mdspan.hpp:206
static constexpr auto static_extent(rank_type r) noexcept -> size_t
Definition mdspan.hpp:55
typename layout_type::template mapping< extents_type > mapping_type
Definition mdspan.hpp:42
remove_cv_t< element_type > value_type
Definition mdspan.hpp:44
constexpr auto extents() const noexcept -> extents_type const &
Definition mdspan.hpp:197
constexpr auto size() const noexcept -> size_type
Definition mdspan.hpp:200
static constexpr auto is_always_strided() -> bool
Definition mdspan.hpp:211
constexpr mdspan(mdspan const &rhs)=default
If Type is an array type, provides the member constant value equal to the number of dimensions of the...
Definition rank.hpp:16
A non-owning view over a contiguous sequence of objects.
Definition span.hpp:83