4#ifndef TETL_MDSPAN_LAYOUT_LEFT_HPP
5#define TETL_MDSPAN_LAYOUT_LEFT_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/is_convertible.hpp>
14#include <etl/_type_traits/is_nothrow_constructible.hpp>
15#include <etl/_utility/index_sequence.hpp>
19template <
typename Extents>
21 using extents_type = Extents;
22 using index_type =
typename extents_type::index_type;
23 using size_type =
typename extents_type::size_type;
24 using rank_type =
typename extents_type::rank_type;
28 constexpr mapping(mapping
const&)
noexcept =
default;
30 constexpr mapping(extents_type
const& ext)
noexcept
35 template <
typename OtherExtents>
36 requires is_constructible_v<extents_type, OtherExtents>
38 mapping<OtherExtents>
const& other
40 : _extents{other.extents()}
44 template <
typename OtherExtents>
45 requires(extents_type::rank() <= 1) && is_constructible_v<extents_type, OtherExtents>
49 : _extents{other.extents()}
53 template <
typename OtherExtents>
54 explicit(extents_type::rank() > 0)
constexpr mapping(
layout_stride::mapping<OtherExtents>
const&);
56 constexpr auto operator=(mapping
const&)
noexcept -> mapping& =
default;
58 [[nodiscard]]
constexpr auto extents()
const noexcept -> extents_type
const&
65 return static_cast<index_type>(
extents().fwd_prod_of_extents(extents_type::rank()));
68 template <
typename... Indices>
69 requires(
sizeof...(Indices) == extents_type::rank())
70 && (is_convertible_v<Indices, index_type> && ...)
71 && (is_nothrow_constructible_v<index_type, Indices> && ...)
72 [[nodiscard]]
constexpr auto operator()(Indices... indices)
const noexcept -> index_type
74 return [&]<size_t... Is>(index_sequence<Is...> ) {
75 return static_cast<index_type>(((
static_cast<index_type>(indices) * stride(Is)) + ... + 0));
76 }(index_sequence_for<Indices...>{});
79 [[nodiscard]]
constexpr auto stride(rank_type r)
const noexcept -> index_type
80 requires(extents_type::rank() > 0)
82 TETL_PRECONDITION(r < extents_type::rank());
83 return static_cast<index_type>(_extents.fwd_prod_of_extents(r));
99 [[nodiscard]]
static constexpr auto is_unique()
noexcept ->
bool
107 [[nodiscard]]
static constexpr auto is_strided()
noexcept ->
bool
112 template <
typename OtherExtents>
113 friend constexpr auto operator==(mapping
const& lhs, mapping<OtherExtents>
const& rhs)
noexcept ->
bool
115 return lhs.extents() == rhs.extents();
141 TETL_NO_UNIQUE_ADDRESS extents_type _extents{};
Definition adjacent_find.hpp:9
constexpr mapping(extents_type const &ext) noexcept
Definition layout_left.hpp:30
constexpr auto operator()(Indices... indices) const noexcept -> index_type
Definition layout_left.hpp:72
constexpr mapping() noexcept=default
explicit(extents_type::rank() > 0) const expr mapping(layout_stride constexpr auto operator=(mapping const &) noexcept -> mapping &=default
static constexpr auto is_exhaustive() noexcept -> bool
Definition layout_left.hpp:103
static constexpr auto is_always_exhaustive() noexcept -> bool
Definition layout_left.hpp:90
friend constexpr auto operator==(mapping const &lhs, mapping< OtherExtents > const &rhs) noexcept -> bool
Definition layout_left.hpp:113
constexpr explicit(not is_convertible_v< OtherExtents, extents_type >) mapping(layout_right
Definition layout_left.hpp:46
static constexpr auto is_always_strided() noexcept -> bool
Definition layout_left.hpp:94
static constexpr auto is_strided() noexcept -> bool
Definition layout_left.hpp:107
static constexpr auto is_always_unique() noexcept -> bool
Definition layout_left.hpp:86
constexpr auto stride(rank_type r) const noexcept -> index_type requires(extents_type::rank() > 0)
Definition layout_left.hpp:79
static constexpr auto is_unique() noexcept -> bool
Definition layout_left.hpp:99
constexpr mapping(mapping const &) noexcept=default
constexpr auto extents() const noexcept -> extents_type const &
Definition layout_left.hpp:58
constexpr explicit(not is_convertible_v< OtherExtents, extents_type >) mapping(mapping< OtherExtents > const &other) noexcept
Definition layout_left.hpp:37
constexpr auto required_span_size() const noexcept -> index_type
Definition layout_left.hpp:63