-
#include "tensorstore/array.h"
-
template <typename Element,
DimensionIndex Rank = dynamic_rank,
ArrayOriginKind OriginKind = zero_origin>
using tensorstore::ArrayView = Array<Element, Rank, OriginKind, view>; Convenience alias for an unowned reference to an in-memory multi-dimensional array with an arbitrary strided layout.
This type does not manage the ownership of the array data or layout, and therefore the user must ensure it is the responsibility of the user to ensure that an ArrayView pointing to invalid memory is not used.
This type is particularly useful as a function parameter type when a reference to neither the array data nor the layout is retained after the function returns, because this usage is guaranteed to be safe and avoids unnecessary copies and atomic reference counting operations.
Example usage:
snippet tensorstore/array_test.cc ArrayView usage example
Logically,
ArrayView
combines anElementPointer<Element>
, which represents an unowned reference to the array with aStridedLayoutView<Rank>
, which represents an unowned reference to a layout, and is well suited for use as the type of function parameters that will not be used (via copying) after the function returns.The related type
SharedArrayView
supports optional shared ownership semantics for the array data it references.The related type
Array
represents the layout with value semantics rather than unowned reference semantics, and supports optional shared ownership semantics for the array data it references.- Template Parameters:¶
- typename Element¶
Specifies the compile-time element type. A type of
void
orconst void
indicates that the element type will be determined at run time.- DimensionIndex Rank = dynamic_rank¶
Specifies the compile-time rank of the array. A value of
dynamic_rank
indicates that the rank will be determined at run time.