-
#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 ashape
vector.BoxView
has shallow assignment semantics likestd::string_view
andspan
, meaning assignment rebinds it to differentorigin
andshape
vectors. Equality comparison is deep (compares the contents of theorigin
andshape
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.
-
using IndexIntervalType =
std::conditional_t<Mutable, IndexIntervalRef, IndexInterval>; Return type of
operator[]
representing an interval.
Constructors¶
- 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 rank, IndexType* origin, IndexType* shape);
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_t, BoxType&& other);
Unchecked conversion.
Methods¶
- BoxView& operator=(BoxType&& other);
Rebinds this box view to refer to the origin and shape vectors of another box.
- IndexIntervalType operator[](DimensionIndex i) const;
Returns the index interval for dimension
i
.
- Index num_elements() const;
Returns the product of the extents.
- bool is_empty() const;
Returns
true
ifnum_elements() == 0
.
- void DeepAssign(const BoxType& other) const;
Copies the contents of
other.origin()
andother.shape()
toorigin()
andshape()
, respectively.
- void Fill(IndexInterval interval = {}) const;
Fills
origin()
withinterval.inclusive_min()
andshape
withinterval.size()
.
- auto operator()(Transformable&& transformable) const;
Slices a supported type by a box.