12#ifndef ARCCORE_BASE_SPAN_H
13#define ARCCORE_BASE_SPAN_H
49template <
typename T,
typename SizeType>
77template <
typename SizeType>
78class DynamicExtentStorage
80 template <
typename T,
typename SpanSizeType, SpanSizeType SpanExtent>
81 friend class ::Arcane::SpanImpl;
85 explicit constexpr DynamicExtentStorage(SizeType s) noexcept
91 constexpr SizeType size()
const noexcept {
return m_size; }
102 static void _throwBadSize [[noreturn]] (
Int64 wanted_size,
Int64 expected_size);
106template <
typename SizeType, SizeType FixedExtent>
109 template <
typename T,
typename SpanSizeType, SpanSizeType SpanExtent>
110 friend class ::Arcane::SpanImpl;
114 explicit constexpr ExtentStorage([[maybe_unused]] SizeType s)
noexcept
116#if defined(ARCCORE_CHECK) && !defined(ARCCORE_DEVICE_CODE)
117 if (s != FixedExtent)
118 ExtentStorageBase::_throwBadSize(s, FixedExtent);
121 ExtentStorage() =
default;
125 constexpr SizeType size()
const noexcept {
return FixedExtent; }
129 static constexpr SizeType m_size = FixedExtent;
135:
public DynamicExtentStorage<Int32>
137 using BaseClass = DynamicExtentStorage<Int32>;
141 explicit constexpr ExtentStorage(
Int32 s) noexcept
149:
public DynamicExtentStorage<Int64>
151 using BaseClass = DynamicExtentStorage<Int64>;
155 explicit constexpr ExtentStorage(
Int64 s) noexcept
189template <
typename T,
typename SizeType, SizeType Extent>
198 using size_type = SizeType;
199 using ElementType = T;
200 using element_type = ElementType;
201 using value_type =
typename std::remove_cv_t<ElementType>;
202 using const_value_type =
typename std::add_const_t<value_type>;
203 using index_type = SizeType;
204 using difference_type = SizeType;
205 using pointer = ElementType*;
206 using const_pointer =
const ElementType*;
207 using reference = ElementType&;
208 using const_reference =
const ElementType&;
211 using view_type =
typename Impl::ViewTypeT<ElementType>::view_type;
212 using reverse_iterator = std::reverse_iterator<iterator>;
213 using const_reverse_iterator = std::reverse_iterator<const_iterator>;
216 template <
typename X>
217 using is_same_const_type = std::enable_if_t<std::is_same_v<X, T> || std::is_same_v<std::add_const_t<X>, T>>;
219 static constexpr bool IsDynamic = (Extent ==
DynExtent);
231 template <
typename X, SizeType XExtent,
typename = std::enable_if_t<std::is_same_v<const X, T>>>
234 , m_size(from.size())
237 template <SizeType XExtent>
240 , m_size(from.size())
245 constexpr ARCCORE_HOST_DEVICE
SpanImpl(pointer ptr, SizeType asize) noexcept
251 template <std::
size_t N,
typename X,
typename = is_same_const_type<X>>
252 constexpr ARCCORE_HOST_DEVICE
SpanImpl(std::array<X, N>& from)
258 explicit constexpr ARCCORE_HOST_DEVICE
SpanImpl(T* ptr)
requires(!IsDynamic)
263 template <std::
size_t N,
typename X,
typename = is_same_const_type<X>>
264 constexpr ARCCORE_HOST_DEVICE ThatClass&
operator=(std::array<X, N>& from)
275 static constexpr ThatClass
create(pointer ptr, SizeType asize)
noexcept
277 return ThatClass(ptr, asize);
287 constexpr ARCCORE_HOST_DEVICE reference
operator[](SizeType i)
const
289 ARCCORE_CHECK_AT(i, m_size.m_size);
298 constexpr ARCCORE_HOST_DEVICE reference
operator()(SizeType i)
const
300 ARCCORE_CHECK_AT(i, m_size.m_size);
309 constexpr ARCCORE_HOST_DEVICE reference
item(SizeType i)
const
311 ARCCORE_CHECK_AT(i, m_size.m_size);
320 constexpr ARCCORE_HOST_DEVICE
void setItem(SizeType i, const_reference v)
noexcept
322 ARCCORE_CHECK_AT(i, m_size.m_size);
327 constexpr ARCCORE_HOST_DEVICE SizeType
size() const noexcept {
return m_size.m_size; }
329 constexpr ARCCORE_HOST_DEVICE SizeType
sizeBytes() const noexcept
332 return static_cast<SizeType
>(m_size.m_size *
sizeof(value_type));
335 constexpr ARCCORE_HOST_DEVICE SizeType
length() const noexcept {
return m_size.m_size; }
340 constexpr ARCCORE_HOST_DEVICE iterator
begin() const noexcept {
return iterator(m_ptr); }
344 constexpr ARCCORE_HOST_DEVICE iterator
end() const noexcept {
return iterator(m_ptr + m_size.m_size); }
346 constexpr ARCCORE_HOST_DEVICE reverse_iterator
rbegin() const noexcept {
return std::make_reverse_iterator(
end()); }
348 constexpr ARCCORE_HOST_DEVICE reverse_iterator
rend() const noexcept {
return std::make_reverse_iterator(
begin()); }
353 ARCCORE_DEPRECATED_REASON(
"Y2023: Use begin()/end() instead")
362 constexpr ARCCORE_HOST_DEVICE pointer
ptrAt(SizeType index)
const
364 ARCCORE_CHECK_AT(index, m_size.m_size);
365 return m_ptr + index;
369 constexpr ARCCORE_HOST_DEVICE
reference at(SizeType i)
const
376 constexpr ARCCORE_HOST_DEVICE
void setAt(SizeType i, const_reference value)
383 ARCCORE_HOST_DEVICE
inline void fill(T o)
385 for (SizeType i = 0, n = m_size.m_size; i < n; ++i)
395 return view_type(s, m_ptr);
414 constexpr ARCCORE_HOST_DEVICE SubSpanType
subSpan(SizeType abegin, SizeType asize)
const
416 if (abegin >= m_size.m_size)
418 asize = _min(asize, m_size.m_size - abegin);
419 return { m_ptr + abegin, asize };
426 constexpr ARCCORE_HOST_DEVICE SubSpanType
subPart(SizeType abegin, SizeType asize)
const
438 ARCCORE_DEPRECATED_REASON(
"Y2023: use subSpan() instead")
439 constexpr SubSpanType
subView(SizeType abegin, SizeType asize)
const
445 constexpr ARCCORE_HOST_DEVICE SubSpanType
subspan(SizeType abegin, SizeType asize)
const
451 ARCCORE_DEPRECATED_REASON(
"Y2023: use subSpanInterval() instead")
454 return impl::subViewInterval<ThatClass>(*
this, index, nb_interval);
460 return impl::subViewInterval<ThatClass>(*
this, index, nb_interval);
466 return impl::subViewInterval<ThatClass>(*
this, index, nb_interval);
477 template <
class U> ARCCORE_HOST_DEVICE
void copy(
const U& copy_array)
479 Int64 n = copy_array.size();
480 Int64 size_as_int64 = m_size.m_size;
482 const_pointer copy_begin = copy_array.data();
483 pointer to_ptr = m_ptr;
486 SizeType n_as_sizetype =
static_cast<SizeType
>(n);
487 for (SizeType i = 0; i < n_as_sizetype; ++i)
488 to_ptr[i] = copy_begin[i];
492 constexpr ARCCORE_HOST_DEVICE
bool empty() const noexcept {
return m_size.m_size == 0; }
494 ARCCORE_HOST_DEVICE
bool contains(const_reference v)
const
496 for (SizeType i = 0; i < m_size.m_size; ++i) {
509 std::optional<SizeType>
findFirst(const_reference v)
const
511 for (SizeType i = 0; i < m_size.m_size; ++i) {
520 constexpr ARCCORE_HOST_DEVICE
void setArray(
const ArrayView<T>& v)
noexcept
525 constexpr ARCCORE_HOST_DEVICE
void setArray(
const Span<T>& v)
noexcept
539 constexpr ARCCORE_HOST_DEVICE pointer
data() const noexcept {
return m_ptr; }
542 template <
typename X, SizeType Extent2,
typename = std::enable_if_t<std::is_same_v<X, value_type>>>
friend bool
549 template <
typename X, SizeType Extent2,
typename = std::enable_if_t<std::is_same_v<X, value_type>>>
friend bool
556 template <SizeType Extent2>
friend bool
563 template <SizeType Extent2>
friend bool
569 friend inline std::ostream&
operator<<(std::ostream& o,
const ThatClass& val)
583 constexpr void _setArray(pointer v, SizeType s)
noexcept
595 constexpr void _setPtr(pointer v)
noexcept { m_ptr = v; }
603 constexpr void _setSize(SizeType s)
noexcept { m_size = ExtentStorageType(s); }
609 ARCCORE_NO_UNIQUE_ADDRESS ExtentStorageType m_size;
613 static constexpr SizeType _min(SizeType a, SizeType b)
615 return ((a < b) ? a : b);
632template <
typename T, Int64 Extent>
640 using size_type =
Int64;
641 using value_type =
typename BaseClass::value_type;
642 using pointer =
typename BaseClass::pointer;
643 template <
typename X>
644 using is_same_const_type = std::enable_if_t<std::is_same_v<X, T> || std::is_same_v<std::add_const_t<X>, T>>;
645 static constexpr bool IsDynamic = (Extent ==
DynExtent);
653 : BaseClass(from.m_ptr, from.m_size)
657 template <
typename X,
typename = std::enable_if_t<std::is_same_v<X, value_type>>>
659 : BaseClass(from.m_ptr, from.m_size)
662 template <
typename X, Int64 XExtent,
typename = std::enable_if_t<std::is_same_v<const X, T>>>
667 template <
typename X, Int32 XExtent,
typename = std::enable_if_t<std::is_same_v<const X, T>>>
668 constexpr ARCCORE_HOST_DEVICE
Span(
const SmallSpan<X, XExtent>& from) noexcept
669 : BaseClass(from.data(), from.size())
671 template <Int64 XExtent>
675 template <Int32 XExtent>
677 : BaseClass(from.data(), from.size())
682 constexpr ARCCORE_HOST_DEVICE
Span(pointer ptr,
Int64 asize) noexcept
683 : BaseClass(ptr, asize)
687 template <std::
size_t N,
typename X,
typename = is_same_const_type<X>>
688 constexpr ARCCORE_HOST_DEVICE
Span(std::array<X, N>& from) noexcept
689 : BaseClass(from.data(), from.size())
693 explicit constexpr ARCCORE_HOST_DEVICE
Span(T* ptr)
requires(!IsDynamic)
698 template <std::
size_t N,
typename X,
typename = is_same_const_type<X>>
699 constexpr ARCCORE_HOST_DEVICE ThatClass&
operator=(std::array<X, N>& from)
noexcept
710 static constexpr ThatClass
create(pointer ptr, size_type asize)
noexcept
712 return ThatClass(ptr, asize);
756 return impl::subViewInterval<ThatClass>(*
this, index, nb_interval);
762 return impl::subViewInterval<ThatClass>(*
this, index, nb_interval);
772 ARCCORE_DEPRECATED_REASON(
"Y2023: use subSpan() instead")
779 ARCCORE_DEPRECATED_REASON(
"Y2023: use subSpanInterval() instead")
782 return impl::subViewInterval<ThatClass>(*
this, index, nb_interval);
802template <
typename T, Int32 Extent>
810 using size_type =
Int32;
811 using value_type =
typename BaseClass::value_type;
812 using pointer =
typename BaseClass::pointer;
813 template <
typename X>
814 using is_same_const_type = std::enable_if_t<std::is_same_v<X, T> || std::is_same_v<std::add_const_t<X>, T>>;
815 static constexpr bool IsDynamic = (Extent ==
DynExtent);
824 : BaseClass(from.m_ptr, from.m_size)
829 template <typename X, typename = std::enable_if_t<std::is_same<X, value_type>::value>>
831 : BaseClass(from.m_ptr, from.m_size)
835 template <typename X, typename = std::enable_if_t<std::is_same<X, value_type>::value>>
840 template <Int32 XExtent>
848 : BaseClass(ptr, asize)
851 template <std::
size_t N,
typename X,
typename = is_same_const_type<X>>
852 constexpr ARCCORE_HOST_DEVICE
SmallSpan(std::array<X, N>& from)
857 explicit constexpr ARCCORE_HOST_DEVICE
SmallSpan(T* ptr)
requires(!IsDynamic)
862 template <std::
size_t N,
typename X,
typename = is_same_const_type<X>>
863 constexpr ARCCORE_HOST_DEVICE ThatClass&
operator=(std::array<X, N>& from)
873 static constexpr ThatClass
create(pointer ptr, size_type asize)
noexcept
875 return ThatClass(ptr, asize);
919 return impl::subViewInterval<ThatClass>(*
this, index, nb_interval);
935 ARCCORE_DEPRECATED_REASON(
"Y2023: use subPart() instead")
942 ARCCORE_DEPRECATED_REASON(
"Y2023: use subPartInterval() instead")
945 return impl::subViewInterval<ThatClass>(*
this, index, nb_interval);
960template <
typename T,
typename SizeType>
inline void
963 impl::dumpArray(o, val, max_print);
977template <
typename DataType,
typename IntegerType,
typename SizeType>
inline void
982 const Int64 result_size = indexes.
size();
983 [[maybe_unused]]
const Int64 my_size = values.
size();
984 const DataType* ptr = values.
data();
985 for (
Int64 i = 0; i < result_size; ++i) {
986 IntegerType index = indexes[i];
987 ARCCORE_CHECK_AT(index, my_size);
988 result[i] = ptr[index];
1003template <
typename DataType>
inline void
1018template <
typename DataType>
inline void
1030template <
typename DataType,
typename SizeType, SizeType Extent>
1031inline typename Impl::SpanTypeFromSize<const std::byte, SizeType>::SpanType
1034 return {
reinterpret_cast<const std::byte*
>(s.
data()), s.
sizeBytes() };
1040template <
typename DataType>
1041inline SmallSpan<const std::byte>
1050template <
typename DataType>
1051inline SmallSpan<const std::byte>
1065template <
typename DataType,
typename SizeType, SizeType Extent,
1066 typename std::enable_if_t<!std::is_const<DataType>::value,
int> = 0>
1067inline typename Impl::SpanTypeFromSize<std::byte, SizeType>::SpanType
1070 return {
reinterpret_cast<std::byte*
>(s.
data()), s.
sizeBytes() };
1078template <
typename DataType>
inline SmallSpan<std::byte>
1090 template <
typename ByteType,
typename DataType, Int64 Extent>
inline Span<DataType>
1091 asSpanInternal(Span<ByteType, Extent> bytes)
1093 Int64 size = bytes.
size();
1096 static constexpr Int64 data_type_size =
static_cast<Int64>(
sizeof(DataType));
1097 static_assert(data_type_size > 0,
"Bad datatype size");
1098 ARCCORE_ASSERT((size % data_type_size) == 0, (
"Size is not a multiple of sizeof(DataType)"));
1099 auto* ptr =
reinterpret_cast<DataType*
>(bytes.data());
1100 return { ptr, size / data_type_size };
1103 template <
typename ByteType,
typename DataType, Int32 Extent>
inline SmallSpan<DataType>
1104 asSmallSpanInternal(SmallSpan<ByteType, Extent> bytes)
1106 Int32 size = bytes.size();
1109 static constexpr Int32 data_type_size =
static_cast<Int32>(
sizeof(DataType));
1110 static_assert(data_type_size > 0,
"Bad datatype size");
1111 ARCCORE_ASSERT((size % data_type_size) == 0, (
"Size is not a multiple of sizeof(DataType)"));
1112 auto* ptr =
reinterpret_cast<DataType*
>(bytes.data());
1113 return { ptr, size / data_type_size };
1128 return impl::asSpanInternal<std::byte, DataType, Extent>(bytes);
1135template <
typename DataType, Int64 Extent>
inline Span<const DataType>
1138 return impl::asSpanInternal<const std::byte, const DataType, Extent>(bytes);
1145template <
typename DataType, Int32 Extent>
inline SmallSpan<DataType>
1148 return impl::asSmallSpanInternal<std::byte, DataType, Extent>(bytes);
1155template <
typename DataType, Int32 Extent>
inline SmallSpan<const DataType>
1158 return impl::asSmallSpanInternal<const std::byte, const DataType, Extent>(bytes);
1167template <
typename DataType,
size_t SizeType>
inline Span<DataType, SizeType>
1171 return { s.data(), size };
1177template <
typename DataType,
size_t SizeType>
inline SmallSpan<DataType, SizeType>
1181 return { s.data(), size };
1192extern "C++" ARCCORE_BASE_EXPORT
void
1193binaryWrite(std::ostream& ostr,
const Span<const std::byte>& bytes);
1200extern "C++" ARCCORE_BASE_EXPORT
void
1201binaryRead(std::istream& istr,
const Span<std::byte>& bytes);
Types and functions associated with the classes ArrayView and ConstArrayView.
Iterator over Arccore array classes.
Interval over Arccore array classes.
Modifiable view of an array of type T.
Constant view of an array of type T.
Specialization for the compile-time known number of elements.
To have the type (SmallSpan or Span) depending on the size (Int32 or Int64).
View of an array of elements of type T.
constexpr __host__ __device__ SmallSpan< T, DynExtent > subspan(Int32 abegin, Int32 asize) const
Sub-view starting from element abegin and containing asize elements.
constexpr __host__ __device__ SmallSpan< Pointer > subViewInterval(Int32 index, Int32 nb_interval) const
constexpr __host__ __device__ ThatClass & operator=(std::array< X, N > &from)
Copy assignment operator.
constexpr __host__ __device__ SmallSpan< T, DynExtent > subSpanInterval(Int32 index, Int32 nb_interval) const
Sub-view corresponding to the interval index over nb_interval.
constexpr __host__ __device__ SmallSpan< T, DynExtent > subPart(Int32 abegin, Int32 asize) const
Sub-view starting from element abegin and containing asize elements.
SmallSpan()=default
Constructs an empty view.
constexpr __host__ __device__ SmallSpan(const ArrayView< value_type > &from) noexcept
Copy constructor from another view.
constexpr __host__ __device__ SmallSpan(pointer ptr, Int32 asize) noexcept
constexpr __host__ __device__ SmallSpan< Pointer > subView(Int32 abegin, Int32 asize) const
constexpr __host__ __device__ SmallSpan(T *ptr)
Constructs a view from a pointer with a fixed size.
static constexpr ThatClass create(pointer ptr, size_type asize) noexcept
Constructs a view over a memory region starting at ptr and.
constexpr __host__ __device__ SmallSpan< T, DynExtent > subSpan(Int32 abegin, Int32 asize) const
Sub-view starting from element abegin and containing asize elements.
constexpr __host__ __device__ ThatClass subPartInterval(Int32 index, Int32 nb_interval) const
Sub-view corresponding to the interval index over nb_interval.
View of an array of elements of type T.
constexpr __host__ __device__ SpanImpl(pointer ptr, SizeType asize) noexcept
constexpr __host__ __device__ SpanImpl(const SpanImpl< X, SizeType, XExtent > &from) noexcept
Copy constructor from another view.
constexpr view_type smallView()
Constant view of this view.
__host__ __device__ void copy(const U ©_array)
Copies the array copy_array into the instance.
constexpr SubSpanType subView(SizeType abegin, SizeType asize) const
friend bool operator==(const SpanImpl< T, SizeType, Extent > &rhs, const SpanImpl< X, SizeType, Extent2 > &lhs)
Equality operator (valid if T is const but not X).
constexpr __host__ __device__ SpanImpl(std::array< X, N > &from)
Constructs a view from a std::array.
std::optional< SizeType > findFirst(const_reference v) const
constexpr void _setArray(pointer v, SizeType s) noexcept
Modifies the array pointer and size.
constexpr __host__ __device__ SpanImpl(T *ptr)
Constructs a view from a pointer with a fixed size.
constexpr __host__ __device__ pointer data() const noexcept
constexpr __host__ __device__ SizeType length() const noexcept
Number of elements in the array.
constexpr __host__ __device__ iterator begin() const noexcept
Iterator for the first element of the array.
__host__ __device__ void fill(T o)
Fills the array with the value o.
constexpr __host__ __device__ pointer ptrAt(SizeType index) const
Address of the index-th element.
constexpr __host__ __device__ reference operator()(SizeType i) const
i-th element of the array.
constexpr __host__ __device__ reference operator[](SizeType i) const
i-th element of the array.
ArrayRange< pointer > range() const
constexpr __host__ __device__ bool empty() const noexcept
Returns true if the array is empty (zero dimension).
constexpr SubSpanType subViewInterval(SizeType index, SizeType nb_interval) const
constexpr __host__ __device__ SubSpanType subSpan(SizeType abegin, SizeType asize) const
Sub-view starting from element abegin and containing asize elements.
constexpr __host__ __device__ reference item(SizeType i) const
i-th element of the array.
constexpr ConstArrayView< value_type > constSmallView() const
Constant view of this view.
friend bool operator==(const SpanImpl< T, SizeType, Extent > &rhs, const SpanImpl< T, SizeType, Extent2 > &lhs)
Equality operator.
constexpr SubSpanType subPartInterval(SizeType index, SizeType nb_interval) const
Sub-view corresponding to the interval index over nb_interval.
__host__ __device__ bool contains(const_reference v) const
Returns true if the array contains the element with value v.
constexpr __host__ __device__ ThatClass & operator=(std::array< X, N > &from)
Copy assignment operator.
constexpr __host__ __device__ iterator end() const noexcept
Iterator for the element after the end of the array.
constexpr void _setPtr(pointer v) noexcept
Modifies the array start pointer.
friend bool operator!=(const SpanImpl< T, SizeType, Extent > &rhs, const SpanImpl< X, SizeType, Extent2 > &lhs)
Inequality operator (valid if T is const but not X).
constexpr __host__ __device__ reverse_iterator rend() const noexcept
Reverse iterator for the element after the end of the array.
constexpr __host__ __device__ SizeType size() const noexcept
constexpr __host__ __device__ SizeType sizeBytes() const noexcept
Returns the size of the array in bytes.
constexpr __host__ __device__ reverse_iterator rbegin() const noexcept
Reverse iterator for the first element of the array.
friend bool operator!=(const SpanImpl< T, SizeType, Extent > &rhs, const SpanImpl< T, SizeType, Extent2 > &lhs)
Inequality operator.
constexpr void _setSize(SizeType s) noexcept
Modifies the array size.
constexpr __host__ __device__ SubSpanType subspan(SizeType abegin, SizeType asize) const
For C++20 compatibility.
constexpr __host__ __device__ SubSpanType subPart(SizeType abegin, SizeType asize) const
Sub-view starting from element abegin and containing asize elements.
constexpr __host__ __device__ SpanImpl() noexcept
Constructs an empty view.
constexpr SubSpanType subSpanInterval(SizeType index, SizeType nb_interval) const
Sub-view corresponding to the interval index over nb_interval.
constexpr __host__ __device__ void setItem(SizeType i, const_reference v) noexcept
Sets the i-th element of the array.
static constexpr ThatClass create(pointer ptr, SizeType asize) noexcept
Constructs a view on a memory region starting at ptr and.
std::enable_if_t< std::is_same_v< X, T >||std::is_same_v< std::add_const_t< X >, T > > is_same_const_type
View of an array of elements of type T.
constexpr __host__ __device__ Span< T, DynExtent > subPart(Int64 abegin, Int64 asize) const
Sub-view starting from element abegin and containing asize elements.
constexpr __host__ __device__ Span< T, DynExtent > subSpanInterval(Int64 index, Int64 nb_interval) const
Sub-view corresponding to the interval index over nb_interval.
static constexpr ThatClass create(pointer ptr, size_type asize) noexcept
Constructs a view on a memory area starting at ptr and.
constexpr __host__ __device__ Span(std::array< X, N > &from) noexcept
Constructs a view from a std::array.
constexpr __host__ __device__ Span< DataType > subView(Int64 abegin, Int64 asize) const
constexpr __host__ __device__ Span(pointer ptr, Int64 asize) noexcept
constexpr __host__ __device__ ThatClass & operator=(std::array< X, N > &from) noexcept
Copy assignment operator.
constexpr __host__ __device__ Span(T *ptr)
Constructs a view from a pointer with a fixed size.
constexpr __host__ __device__ Span(const ArrayView< value_type > &from) noexcept
Copy constructor from another view.
Span()=default
Constructs an empty view.
constexpr __host__ __device__ Span< DataType > subViewInterval(Int64 index, Int64 nb_interval) const
constexpr __host__ __device__ Span< T, DynExtent > subPartInterval(Int64 index, Int64 nb_interval) const
Sub-view corresponding to the interval index over nb_interval.
constexpr __host__ __device__ Span< T, DynExtent > subSpan(Int64 abegin, Int64 asize) const
Sub-view starting from element abegin and containing asize elements.
constexpr __host__ __device__ Span< T, DynExtent > subspan(Int64 abegin, Int64 asize) const
Sub-view starting from element abegin and containing asize elements.
-- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature --
constexpr __host__ __device__ Integer arccoreCheckArraySize(unsigned long long size)
Checks that size can be converted into an 'Integer' to serve as an array size. If possible,...
std::int64_t Int64
Signed integer type of 64 bits.
Int32 Integer
Type representing an integer.
constexpr Int32 DynExtent
Constant to indicate that an array dimension is dynamic.
__host__ __device__ void arccoreCheckAt(Int64 i, Int64 max_size)
Checks for potential array overflow.
void dumpArray(std::ostream &o, ConstArrayView< T > val, int max_print)
Displays the values of array val to the stream o.
void sampleSpan(Span< const DataType > values, Span< const Int64 > indexes, Span< DataType > result)
Extracts a sub-array from a list of indices.
SmallSpan< DataType > asSmallSpan(SmallSpan< std::byte, Extent > bytes)
Converts a SmallSpan<std::byte> into a SmallSpan<DataType>.
Span< DataType > asSpan(Span< std::byte, Extent > bytes)
Converts a Span<std::byte> into a Span<DataType>.
void binaryRead(std::istream &istr, const Span< std::byte > &bytes)
Reads the content of bytes from the stream istr in binary format.
Impl::SpanTypeFromSize< conststd::byte, SizeType >::SpanType asBytes(const SpanImpl< DataType, SizeType, Extent > &s)
Converts the view into an array of non-modifiable bytes.
Impl::SpanTypeFromSize< std::byte, SizeType >::SpanType asWritableBytes(const SpanImpl< DataType, SizeType, Extent > &s)
Converts the view into an array of modifiable bytes.
void binaryWrite(std::ostream &ostr, const Span< const std::byte > &bytes)
Writes the content of bytes to the stream ostr in binary format.
void _sampleSpan(SpanImpl< const DataType, SizeType > values, SpanImpl< const IntegerType, SizeType > indexes, SpanImpl< DataType, SizeType > result)
Extracts a sub-array from a list of indices.
std::ostream & operator<<(std::ostream &ostr, eItemKind item_kind)
Output operator for a stream.
std::int32_t Int32
Signed integer type of 32 bits.