#include "tensorstore/array.h"
template <ContainerKind LayoutCKind = view,
          typename ElementTag,
          DimensionIndex Rank,
          ArrayOriginKind OriginKind,
          ContainerKind SourceCKind,
          typename Indices>
  
requires IsCompatiblePartialIndexVector<
      
RankConstraint::FromInlineRank(Rank),
      Indices>
Array<
    
typename ElementTagTraits<ElementTag>::Element,
    SubArrayStaticRank<RankConstraint::FromInlineRank(Rank), Indices>,
    OriginKind,
    LayoutCKind>
tensorstore::SubArray(
    
const Array<ElementTag, Rank, OriginKind, SourceCKind>& array,
    
const Indicesindices);
template <ContainerKind LayoutCKind = view,
          typename Element,
          DimensionIndex Rank,
          ArrayOriginKind OriginKind,
          ContainerKind SourceCKind,
          typename Indices>
SharedArray<
    
Element,
    SubArrayStaticRank<RankConstraint::FromInlineRank(Rank), Indices>,
    OriginKind,
    LayoutCKind>
tensorstore::SharedSubArray(
    
const SharedArray<Element, Rank, OriginKind, SourceCKind>& array,
    
const Indicesindices);

Returns a reference to the sub-array obtained by subscripting the first tensorstore::span(indices).size() dimensions of array.

SubArray always returns an array with an unowned data pointer, while SharedSubArray returns an array that shares ownership of the data.

Template Parameters:
ContainerKind LayoutCKind = view

Specifies whether to return a copy or view of the sub-array layout.

Parameters:
const Array<ElementTag, Rank, OriginKind, SourceCKind> &array
const SharedArray<Element, Rank, OriginKind, SourceCKind> &array

The source array.

const Indices &indices

A span-compatible index array. May be specified as a braced list, e.g. SubArray(array, {1, 2}) or SharedSubArray(array, {1, 2}).

Dchecks:

array.rank() >= tensorstore::span(indices).size().

Dchecks:

0 <= tensorstore::span(indices)[i] < array.shape()[i] for 0 <= i < tensorstore::span(indices).size().

Returns:

The sub array.