-
#include "tensorstore/array.h"
-
template <typename SourcePointer = ElementPointer,
typename LayoutOrder = ContiguousLayoutOrder>
requires std::is_convertible_v<SourcePointer, ElementPointer> &&
(LayoutContainerKind == container) &&
(OriginKind == offset_origin) &&
IsContiguousLayoutOrder<
LayoutOrder,
RankConstraint::FromInlineRank(Rank)>
tensorstore::
Array<ElementTagType, Rank, OriginKind, LayoutContainerKind>::
Array(SourcePointer element_pointer,
BoxView<static_rank> domain,
LayoutOrder order = c_order); Constructs an array with a contiguous layout from an implicitly convertible
element_pointer
anddomain
.The
element_pointer
is assumed to point to the element atdomain.origin()
, not the element at the zero position vector.Example:
int data[6] = {1, 2, 3, 4, 5, 6}; auto c_array = Array(&data[0], Box({1, 2}, {2, 3})); EXPECT_EQ(MakeOffsetArray<int>({1, 2}, {{1, 2, 3}, {4, 5, 6}}), array); auto f_array = Array(&data[0], Box({1, 2}, {3, 2}), fortran_order); EXPECT_EQ(MakeOffsetArray<int>({1, 2}, {{1, 4}, {2, 5}, {3, 6}}), array);
Warning
The caller is responsible for ensuring that
domain
andorder
are valid forelement_pointer
. This function does not check them in any way.