#include "tensorstore/box.h"
template <DimensionIndex Rank = dynamic_rank, bool Mutable = false>
class tensorstore::BoxView;

Represents an unowned view of a Rank-dimensional hyperrectangle.

The hyperrectangle is represented as an origin vector and a shape vector.

BoxView has shallow assignment semantics like std::string_view and span, meaning assignment rebinds it to different origin and shape vectors. Equality comparison is deep (compares the contents of the origin and shape vectors, not the pointers themselves).

Template Parameters:
DimensionIndex Rank = dynamic_rank

Specifies the number of dimensions at compile time, or equal to dynamic_rank to indicate that the number of dimensions will be specified at run time.

bool Mutable = false

Specifies whether the view is mutable (rather than const).

Data members

constexpr const DimensionIndex static_rank = Rank;

Compile-time rank, or dynamic_rank if the rank is specified at runtime.

Types

using RankType = StaticOrDynamicRank<Rank>;

Type representing a static or dynamic rank.

type IndexType;

Element type of origin and shape.

using IndexIntervalType =
   
 std::conditional_t<Mutable, IndexIntervalRef, IndexInterval>;

Return type of operator[] representing an interval.

Constructors

BoxView();

Constructs an unbounded box view of rank RankType().

explicit BoxView(RankType rank);

Constructs an unbounded box view of the given rank.

explicit BoxView(span<const Index, Rank> shape);
explicit BoxView(IndexType (&shape)[N]);

Constructs from a shape vector and an all-zero origin vector.

explicit BoxView(span<IndexType, Rank> origin,
                 
span<IndexType, Rank> shape);
explicit BoxView(IndexType (&origin)[N]IndexType (&shape)[N]);

Constructs from an origin and shape vector.

explicit BoxView(RankType rankIndexTypeoriginIndexTypeshape);

Constructs from a rank, an origin base pointer, and a shape base pointer.

BoxView(BoxType&other);

Constructs a box view that refers to the origin and shape vectors of an existing box.

explicit BoxView(unchecked_tBoxType&other);

Unchecked conversion.

Methods

BoxViewoperator=(BoxType&other);

Rebinds this box view to refer to the origin and shape vectors of another box.

RankType rank() const;

Returns the rank of the box.

IndexIntervalType operator[](DimensionIndex i) const;

Returns the index interval for dimension i.

span<IndexType, Rank> origin() const;

Returns the origin array of length rank().

span<IndexType, Rank> shape() const;

Returns the shape array of length rank().

Index num_elements() const;

Returns the product of the extents.

bool is_empty() const;

Returns true if num_elements() == 0.

void DeepAssign(const BoxTypeother) const;

Copies the contents of other.origin() and other.shape() to origin() and shape(), respectively.

void Fill(IndexInterval interval = {}) const;

Fills origin() with interval.inclusive_min() and shape with interval.size().

auto operator()(Transformable&transformable) const;

Slices a supported type by a box.