5 #ifndef DUNE_COMMON_STD_LAYOUT_LEFT_HH 6 #define DUNE_COMMON_STD_LAYOUT_LEFT_HH 18 template <
class Extents>
19 class layout_left::mapping
31 constexpr
mapping () noexcept = default;
42 template <
class OtherExtents,
43 std::enable_if_t<std::is_constructible_v<extents_type, OtherExtents>,
int> = 0>
44 #if __cpp_conditional_explicit >= 201806L 45 explicit(!std::is_convertible_v<OtherExtents, extents_type>)
53 std::enable_if_t<(E::rank() <= 1), int> = 0,
54 std::enable_if_t<std::is_constructible_v<extents_type, OtherExtents>,
int> = 0>
55 #if __cpp_conditional_explicit >= 201806L 56 explicit(!std::is_convertible_v<OtherExtents, extents_type>)
63 template <
class OtherExtents,
64 std::enable_if_t<std::is_constructible_v<extents_type, OtherExtents>,
int> = 0>
65 #if __cpp_conditional_explicit >= 201806L 66 explicit(extents_type::rank() > 0)
72 if constexpr(extents_type::rank() > 0) {
74 for (
rank_type r = 0; r < extents_type::rank()-1; ++r) {
78 assert(m.
strides(extents_type::rank()-1) == prod);
90 template <
class... Indices,
91 std::enable_if_t<(
sizeof...(Indices) == extents_type::rank()),
int> = 0,
92 std::enable_if_t<(... && std::is_convertible_v<Indices, index_type>),
int> = 0,
93 std::enable_if_t<(... && std::is_nothrow_constructible_v<Indices, index_type>),
int> = 0>
94 constexpr
index_type operator() (Indices... ii)
const noexcept
96 const std::array indices{
index_type(std::move(ii))...};
98 for (
rank_type r = 1; r < extents_type::rank(); ++r) {
99 const rank_type j = extents_type::rank()-r;
100 value = indices[j-1] + extents_.extent(j-1) * value;
115 static constexpr
bool is_unique () noexcept {
return true; }
117 static constexpr
bool is_strided () noexcept {
return true; }
121 std::enable_if_t<(E::rank() > 0),
int> = 0>
124 assert(
i < extents_type::rank());
131 template <
class OtherExtents,
132 std::enable_if_t<(Extents::rank() == OtherExtents::rank()), int> = 0>
135 return a.extents_ == b.extents_;
144 #endif // DUNE_COMMON_STD_LAYOUT_LEFT_HH A layout mapping where the strides are user-defined.
Definition: fwd_layouts.hh:42
Namespace for features backported from new C++ standards.
Definition: algorithm.hh:19
constexpr index_type operator()() const noexcept
The default offset for rank-0 tensors is 0.
Definition: layout_left.hh:106
constexpr index_type stride(rank_type i) const noexcept
The stride is the product of the extents E(0)*E(1)*...*E(i-1)
Definition: layout_left.hh:122
typename extents_type::index_type index_type
Definition: layout_left.hh:27
friend constexpr bool operator==(const mapping &a, const mapping< OtherExtents > &b) noexcept
Definition: layout_left.hh:133
#define DUNE_NO_UNIQUE_ADDRESS
Definition: no_unique_address.hh:24
Extents extents_type
Definition: layout_left.hh:24
static constexpr bool is_exhaustive() noexcept
Definition: layout_left.hh:116
constexpr const extents_type & extents() const noexcept
Definition: layout_left.hh:86
constexpr mapping() noexcept=default
The default construction is possible for default constructible extents.
static constexpr bool is_always_exhaustive() noexcept
Definition: layout_left.hh:112
constexpr const extents_type & extents() const noexcept
Definition: layout_stride.hh:87
I i
Definition: hybridmultiindex.hh:328
static constexpr bool is_strided() noexcept
Definition: layout_left.hh:117
constexpr index_type required_span_size() const noexcept
Definition: layout_left.hh:87
constexpr const extents_type & extents() const noexcept
Definition: layout_right.hh:86
static constexpr bool is_always_unique() noexcept
Definition: layout_left.hh:111
constexpr mapping & operator=(const mapping &) noexcept=default
Copy-assignment for the mapping.
static constexpr bool is_unique() noexcept
Definition: layout_left.hh:115
constexpr const strides_type & strides() const noexcept
Get the array of all strides.
Definition: layout_stride.hh:129
typename extents_type::size_type size_type
Definition: layout_left.hh:25
static constexpr bool is_always_strided() noexcept
Definition: layout_left.hh:113
A layout mapping where the leftmost extent has stride 1.
Definition: fwd_layouts.hh:19
A layout mapping where the rightmost extent has stride 1.
Definition: fwd_layouts.hh:32
A layout where the leftmost extent has stride 1.For two-dimensional tensors this corresponds to colum...
Definition: fwd_layouts.hh:16
typename extents_type::rank_type rank_type
Definition: layout_left.hh:26