Skip to content

strata::Slice

Part of Views and expressions.

template <tensor_like E, std::size_t... Axes>
class strata::Slice;

E at fixed indices along Axes, an axis less for each: element i... is the operand's at i... with the fixed indices put in at Axes.

What slice<Axes...> gives for a node that has no slice of its own: it reads through the operand, and its cursor is the operand's, moved to the fixed indices once. A node with a better way, a view whose slice is another view, gives that instead.

Template parameters

Name Description
E The operand as it is held, capture_t of what was given: borrowed for an lvalue owner, owned for a temporary one, which makes the slice moved and never copied, else by value.
Axes The axes that are fixed, axes of the operand, in increasing order.

Members

indices_type

using strata::Slice< E, Axes >::indices_type = std::array<std::size_t, sizeof...(Axes)>

The fixed indices, one for each of Axes, in their order.

Slice

constexpr Slice(E operand, const indices_type &indices)

operand at indices along Axes.

Precondition

Each index is less than the operand's extent along its axis.

operand

constexpr const E & operand() const noexcept STRATA_LIFETIMEBOUND

The operand that is sliced.

indices

constexpr const indices_type & indices() const noexcept STRATA_LIFETIMEBOUND

The fixed indices, one for each of Axes.

shape

constexpr shape_type shape() const

The operand's shape without Axes.

cursor

constexpr auto cursor() const

Where a traversal starts: the operand's cursor, moved to the fixed indices along Axes.

operator[]

template <index_like... Indices>
constexpr value_type operator[](Indices... indices) const

The element at a position of the slice: the operand's, with the fixed indices along Axes.

Precondition

Each index is within the extent of its axis; the operand checks it.

slice

template <std::size_t... Outer>
constexpr auto slice(const Slice &sliced, const std::array<std::size_t, sizeof...(Outer)> &indices)

The slice of the slice: one slice of the operand, along the axes both cut, each at its index.