4#ifndef TETL_MDSPAN_LAYOUT_RIGHT_HPP
5#define TETL_MDSPAN_LAYOUT_RIGHT_HPP
7#include <etl/_contracts/check.hpp>
8#include <etl/_mdspan/extents.hpp>
9#include <etl/_mdspan/is_extents.hpp>
10#include <etl/_mdspan/layout.hpp>
11#include <etl/_mdspan/submdspan_extents.hpp>
12#include <etl/_mdspan/submdspan_mapping_result.hpp>
13#include <etl/_type_traits/always_false.hpp>
14#include <etl/_type_traits/is_convertible.hpp>
15#include <etl/_type_traits/is_nothrow_constructible.hpp>
16#include <etl/_utility/index_sequence.hpp>
20template <
typename Extents>
22 using extents_type = Extents;
23 using index_type =
typename extents_type::index_type;
24 using size_type =
typename extents_type::size_type;
25 using rank_type =
typename extents_type::rank_type;
30 constexpr mapping(mapping
const&)
noexcept =
default;
32 constexpr mapping(extents_type
const& ext)
noexcept
37 template <
typename OtherExtents>
38 requires is_constructible_v<extents_type, OtherExtents>
40 mapping<OtherExtents>
const& other
42 : _extents{other.extents()}
46 template <
typename OtherExtents>
47 requires(extents_type::rank() <= 1) && is_constructible_v<extents_type, OtherExtents>
51 : _extents{other.extents()}
55 template <
typename OtherExtents>
56 constexpr explicit(extents_type::rank() > 0) mapping(
layout_stride::mapping<OtherExtents>
const&)
noexcept;
58 constexpr auto operator=(mapping
const&)
noexcept -> mapping& =
default;
61 [[nodiscard]]
constexpr auto extents()
const noexcept -> extents_type
const&
68 return static_cast<index_type>(
extents().fwd_prod_of_extents(extents_type::rank()));
71 template <
typename... Indices>
72 requires(
sizeof...(Indices) == extents_type::rank())
73 and (is_convertible_v<Indices, index_type>
and ...)
74 and (is_nothrow_constructible_v<index_type, Indices>
and ...)
75 [[nodiscard]]
constexpr auto operator()(Indices... indices)
const noexcept -> index_type
77 return [&]<size_t... Is>(index_sequence<Is...> ) {
78 return static_cast<index_type>(((
static_cast<index_type>(indices) * stride(Is)) + ... + 0));
79 }(index_sequence_for<Indices...>{});
82 [[nodiscard]]
constexpr auto stride(rank_type r)
const noexcept -> index_type
83 requires(extents_type::rank() > 0)
85 TETL_PRECONDITION(r < extents_type::rank());
86 return static_cast<index_type>(_extents.rev_prod_of_extents(r));
102 [[nodiscard]]
static constexpr auto is_unique()
noexcept ->
bool
110 [[nodiscard]]
static constexpr auto is_strided()
noexcept ->
bool
115 template <
typename OtherExtents>
116 friend constexpr auto operator==(mapping
const& lhs, mapping<OtherExtents>
const& rhs)
noexcept ->
bool
118 return lhs.extents() == rhs.extents();
144 TETL_NO_UNIQUE_ADDRESS extents_type _extents{};
Definition adjacent_find.hpp:9
constexpr mapping(extents_type const &ext) noexcept
Definition layout_right.hpp:32
constexpr mapping() noexcept=default
Indices and constexpr auto operator()(Indices... indices) const noexcept -> index_type
Definition layout_right.hpp:75
static constexpr auto is_exhaustive() noexcept -> bool
Definition layout_right.hpp:106
static constexpr auto is_always_exhaustive() noexcept -> bool
Definition layout_right.hpp:93
friend constexpr auto operator==(mapping const &lhs, mapping< OtherExtents > const &rhs) noexcept -> bool
Definition layout_right.hpp:116
constexpr explicit(!is_convertible_v< OtherExtents, extents_type >) mapping(layout_left
Definition layout_right.hpp:48
static constexpr auto is_always_strided() noexcept -> bool
Definition layout_right.hpp:97
static constexpr auto is_strided() noexcept -> bool
Definition layout_right.hpp:110
static constexpr auto is_always_unique() noexcept -> bool
Definition layout_right.hpp:89
constexpr auto stride(rank_type r) const noexcept -> index_type requires(extents_type::rank() > 0)
Definition layout_right.hpp:82
constexpr explicit(!is_convertible_v< OtherExtents, extents_type >) mapping(mapping< OtherExtents > const &other) noexcept
Definition layout_right.hpp:39
static constexpr auto is_unique() noexcept -> bool
Definition layout_right.hpp:102
constexpr mapping(mapping const &) noexcept=default
constexpr auto extents() const noexcept -> extents_type const &
Definition layout_right.hpp:61
constexpr auto required_span_size() const noexcept -> index_type
Definition layout_right.hpp:66
constexpr explicit(extents_type::rank() > 0) mapping(layout_stride constexpr auto operator=(mapping const &) noexcept -> mapping &=default