3#ifndef TETL_MDSPAN_EXTENTS_HPP
4#define TETL_MDSPAN_EXTENTS_HPP
21template <
typename IndexType,
etl::size_t... Extents>
28 static constexpr auto _rank =
sizeof...(Extents);
30 static constexpr auto _static_extents =
array<
etl::size_t,
sizeof...(Extents)>{Extents...};
40 [[nodiscard]]
static constexpr auto _dynamic_index_inv(
rank_type i)
noexcept ->
rank_type
45 if (_dynamic_index(r) == i) {
59 return _static_extents[i];
72 return _extents[
static_cast<etl::size_t>(_dynamic_index(i))];
79 template <typename OtherIndexType,
etl::
size_t... OtherExtents>
81 sizeof...(OtherExtents) ==
rank()
92 _extents[_dynamic_index(i)] =
static_cast<IndexType
>(e.extent(i));
98 template <
typename... OtherIndexTypes>
102 and (
sizeof...(OtherIndexTypes) ==
rank_dynamic() or
sizeof...(OtherIndexTypes) ==
rank())
105 :
extents{
array<IndexType,
sizeof...(OtherIndexTypes)>{
static_cast<IndexType
>(es)...}}
109 template <
typename OtherIndexType, etl::
size_t N>
117 transform(ext.begin(), ext.end(), _extents.begin(), [](
auto e) { return static_cast<IndexType>(e); });
121 template <
typename OtherIndexType, etl::
size_t N>
131 template <
typename OtherIndexType,
etl::size_t... OtherExtents>
147 template <
typename OtherIndexType>
148 [[nodiscard]]
static constexpr auto index_cast(OtherIndexType&& i)
noexcept -> IndexType
150 return static_cast<IndexType
>(i);
153 [[nodiscard]]
constexpr auto fwd_prod_of_extents(
rank_type i)
const noexcept ->
size_t
155 if constexpr (
rank() == 0) {
160 result *=
static_cast<size_t>(
extent(e));
166 [[nodiscard]]
constexpr auto rev_prod_of_extents(
rank_type i)
const noexcept ->
size_t
169 for (
auto e = i + 1;
e <
rank(); ++
e) {
170 result *=
static_cast<size_t>(
extent(e));
181template <
typename IndexType,
typename Integrals>
184template <
typename IndexType,
etl::size_t... Integrals>
185struct dextents_impl<IndexType, etl::
index_sequence<Integrals...>> {
191template <
typename... Integrals>
195template <typename IndexType,
etl::
size_t Rank>
#define TETL_NO_UNIQUE_ADDRESS
Definition attributes.hpp:41
constexpr auto transform(InputIt first, InputIt last, OutputIt dest, UnaryOp op) -> OutputIt
Applies the given function to a range and stores the result in another range, beginning at dest....
Definition transform.hpp:24
constexpr auto max(Type const &a, Type const &b, Compare comp) noexcept -> Type const &
Returns the greater of a and b, using a compare function.
Definition max.hpp:13
constexpr double e
Definition constants.hpp:29
constexpr auto dynamic_extent
etl::dynamic_extent is a constant of type etl::size_t that is used to differentiate etl::span of stat...
Definition dynamic_extent.hpp:14
constexpr auto cmp_not_equal(T t, U u) noexcept -> bool
Compare the values of two integers t and u. Unlike builtin comparison operators, negative signed inte...
Definition cmp_not_equal.hpp:20
Definition adjacent_find.hpp:8
constexpr auto operator==(inplace_function< R(Args...), Capacity, Alignment > const &f, nullptr_t) noexcept -> bool
Compares a etl::inplace_function with a null pointer. Empty functions (that is, functions without a c...
Definition inplace_function.hpp:262
etl::make_integer_sequence< etl::size_t, Size > make_index_sequence
Definition index_sequence.hpp:15
etl::integer_sequence< etl::size_t, Ints... > index_sequence
Definition index_sequence.hpp:12
extents(Integrals...) -> extents< etl::size_t, etl::size_t((Integrals(), etl::dynamic_extent))... >
typename make_unsigned< T >::type make_unsigned_t
Definition make_unsigned.hpp:75
span(c_array< Type, Extent > &) -> span< Type, Extent >
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
array(T, U...) -> array< T, 1+sizeof...(U)>
One deduction guide is provided for array to provide an equivalent of experimental::make_array for co...
Definition extents.hpp:22
static constexpr auto rank() noexcept -> rank_type
Definition extents.hpp:53
static constexpr auto static_extent(rank_type i) noexcept -> etl::size_t
Definition extents.hpp:57
typename Extents::index_type index_type
Definition extents.hpp:23
explicit(((Extents !=dynamic_extent and OtherExtents==dynamic_extent) or ...) or(numeric_limits< typename Extents::index_type >::max()< numeric_limits< OtherIndexType >::max())) const expr extents(extents< OtherIndexType
etl::size_t rank_type
Definition extents.hpp:25
static constexpr auto rank_dynamic() noexcept -> rank_type
Definition extents.hpp:55
make_unsigned_t< typename Extents::index_type > size_type
Definition extents.hpp:24
OtherExtents const &e noexcept
Definition extents.hpp:88
constexpr extents() noexcept=default
constexpr auto extent(rank_type i) const noexcept -> index_type
Definition extents.hpp:62
Definition numeric_limits.hpp:17