#include "tensorstore/array.h"
template <typename Element,
         
 DimensionIndex Rank = dynamic_rank,
         
 ArrayOriginKind OriginKind = zero_origin>
using tensorstore::SharedArrayView =
   
 Array<Shared<Element>, Rank, OriginKind, view>;

Convenience alias for a reference to an in-memory multi-dimensional array with an arbitrary strided layout and optional shared ownership semantics.

This type manages the ownership of the array data but not the layout, and is primarily useful as a function parameter type when a reference to the array data, but not the layout, may be retained after the function returns. For example, the function may retain a reference to the data along with a new, modified layout.

Logically, SharedArrayView combines a SharedElementPointer<Element>, which represents an unowned reference to, or shared ownership of, the array with a StridedLayoutView<Rank>, which represents an unowned reference to a layout. This type is useful as a function parameter type where ownership of the array data needs to be shared or transferred, but the layout does not need to be copied, possibly because the callee modifies the layout prior to storing the array.

Example usage:

snippet tensorstore/array_test.cc SharedArrayView usage example

The related type Array has value semantics for the layout, and like SharedArrayView supports optional shared ownership semantics for the array data it references.

The related type ArrayView has unowned reference semantics for both the layout and the array data.

Template Parameters:
typename Element

Specifies the compile-time element type. A type of void or const 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.

See also

The related type ArrayView supports optional shared ownership semantics for the array data it references.