#include "tensorstore/array.h"
template <typename SourcePointer = ElementPointer,
         
 typename Shape,
         
 typename LayoutOrder = ContiguousLayoutOrder>
  
requires std::is_convertible_v<SourcePointer, ElementPointer> &&
          
 (LayoutContainerKind == container) &&
          
 IsImplicitlyCompatibleFullIndexVector<static_rank,
                                                
 Shape> &&
          
 IsContiguousLayoutOrder<
               
LayoutOrder,
              
 RankConstraint::FromInlineRank(Rank)>
tensorstore::
    
Array<ElementTagType, Rank, OriginKind, LayoutContainerKind>::
        
Array(SourcePointer element_pointer,
              
const Shapeshape,
              
LayoutOrder order = c_order);
template <typename SourcePointer = ElementPointer,
         
 DimensionIndex ShapeRank,
         
 typename LayoutOrder = ContiguousLayoutOrder>
  
requires std::is_convertible_v<SourcePointer, ElementPointer> &&
          
 (LayoutContainerKind == container) &&
          
 (RankConstraint::Implies(ShapeRank, static_rank)) &&
          
 IsContiguousLayoutOrder<
               
LayoutOrder,
              
 RankConstraint::FromInlineRank(Rank)>
tensorstore::
    
Array<ElementTagType, Rank, OriginKind, LayoutContainerKind>::
        
Array(SourcePointer element_pointer,
              
const Index (&shape)[ShapeRank],
              
LayoutOrder order = c_order);

Constructs an array with a contiguous layout from an implicitly convertible element_pointer and shape.

Example:

int data[6] = {1, 2, 3, 4, 5, 6}; auto c_array = Array(&data[0], {2, 3}); EXPECT_EQ(MakeArray<int>({{1, 2, 3}, {4, 5, 6}}), array);

auto f_array = Array(&data[0], {3, 2}, fortran_order); EXPECT_EQ(MakeArray<int>({{1, 4}, {2, 5}, {3, 6}}), array);

Parameters:
SourcePointer element_pointer

The base/origin pointer of the array.

const Shape &shape
const Index (&shape)[ShapeRank]

The dimensions of the array. May be specified as a braced list, e.g. Array(element_pointer, {2, 3}).

LayoutOrder order = c_order

Specifies the layout order.

Warning

The caller is responsible for ensuring that shape and order are valid for element_pointer. This function does not check them in any way.