Arcane  4.1.12.0
User documentation
Loading...
Searching...
No Matches
Arcane::SmallSpan< T, Extent > Class Template Reference

View of an array of elements of type T. More...

#include <arccore/base/Span.h>

Public Types

using ThatClass = SmallSpan<T, Extent>
using BaseClass = SpanImpl<T, Int32, Extent>
using size_type = Int32
using value_type = typename BaseClass::value_type
using pointer = typename BaseClass::pointer
template<typename X>
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>>
Public Types inherited from Arcane::SpanImpl< T, Int32, Extent >
using ThatClass
using SubSpanType
using size_type
using ElementType
using element_type
using value_type
using const_value_type
using index_type
using difference_type
using pointer
using const_pointer
using reference
using const_reference
using iterator
using const_iterator
using view_type
using reverse_iterator
using const_reverse_iterator
using is_same_const_type
 Indicates if 'X' or 'const X' can be converted to 'T'.

Public Member Functions

 SmallSpan ()=default
 Constructs an empty view.
constexpr __host__ __device__ SmallSpan (const ArrayView< value_type > &from) noexcept
 Copy constructor from another view.
template<typename X, typename = std::enable_if_t<std::is_same<X, value_type>::value>>
constexpr __host__ __device__ SmallSpan (const ConstArrayView< X > &from) noexcept
template<typename X, typename = std::enable_if_t<std::is_same<X, value_type>::value>>
constexpr __host__ __device__ SmallSpan (const SmallSpan< X > &from) noexcept
template<Int32 XExtent>
constexpr __host__ __device__ SmallSpan (const SpanImpl< T, Int32, XExtent > &from) noexcept
constexpr __host__ __device__ SmallSpan (pointer ptr, Int32 asize) noexcept
template<std::size_t N, typename X, typename = is_same_const_type<X>>
constexpr __host__ __device__ SmallSpan (std::array< X, N > &from)
constexpr __host__ __device__ SmallSpan (T *ptr)
 Constructs a view from a pointer with a fixed size.
template<std::size_t N, typename X, typename = is_same_const_type<X>>
constexpr __host__ __device__ ThatClass & operator= (std::array< X, N > &from)
 Copy assignment operator.
constexpr __host__ __device__ SmallSpan< T, DynExtentsubspan (Int32 abegin, Int32 asize) const
 Sub-view starting from element abegin and containing asize elements.
constexpr __host__ __device__ SmallSpan< T, DynExtentsubSpan (Int32 abegin, Int32 asize) const
 Sub-view starting from element abegin and containing asize elements.
constexpr __host__ __device__ SmallSpan< T, DynExtentsubPart (Int32 abegin, Int32 asize) const
 Sub-view starting from element abegin and containing asize elements.
constexpr __host__ __device__ SmallSpan< T, DynExtentsubSpanInterval (Int32 index, Int32 nb_interval) const
 Sub-view corresponding to the interval index over nb_interval.
constexpr __host__ __device__ ThatClass subPartInterval (Int32 index, Int32 nb_interval) const
 Sub-view corresponding to the interval index over nb_interval.
constexpr __host__ __device__ SmallSpan< T > subView (Int32 abegin, Int32 asize) const
 Sub-view starting from element abegin and containing asize elements.
constexpr __host__ __device__ SmallSpan< T > subViewInterval (Int32 index, Int32 nb_interval) const
 Sub-view corresponding to the interval index over nb_interval.
Public Member Functions inherited from Arcane::SpanImpl< T, Int32, Extent >
constexpr __host__ __device__ SpanImpl () noexcept
 Constructs an empty view.
constexpr __host__ __device__ SpanImpl (const SpanImpl< X, Int32, XExtent > &from) noexcept
 Copy constructor from another view.
constexpr __host__ __device__ SpanImpl (const SpanImpl< T, Int32, XExtent > &from) noexcept
constexpr __host__ __device__ SpanImpl (pointer ptr, Int32 asize) noexcept
constexpr __host__ __device__ SpanImpl (std::array< X, N > &from)
 Constructs a view from a std::array.
constexpr __host__ __device__ SpanImpl (T *ptr)
 Constructs a view from a pointer with a fixed size.
constexpr __host__ __device__ ThatClass & operator= (std::array< X, N > &from)
 Copy assignment operator.
constexpr __host__ __device__ reference operator[] (Int32 i) const
 i-th element of the array.
constexpr __host__ __device__ reference operator() (Int32 i) const
 i-th element of the array.
constexpr __host__ __device__ reference item (Int32 i) const
 i-th element of the array.
constexpr __host__ __device__ void setItem (Int32 i, const_reference v) noexcept
 Sets the i-th element of the array.
constexpr __host__ __device__ Int32 size () const noexcept
 Returns the size of the array.
constexpr __host__ __device__ Int32 sizeBytes () const noexcept
 Returns the size of the array in bytes.
constexpr __host__ __device__ Int32 length () const noexcept
 Number of elements in the array.
constexpr __host__ __device__ iterator begin () const noexcept
 Iterator for the first element of the array.
constexpr __host__ __device__ iterator end () const noexcept
 Iterator for the element after the end of the array.
constexpr __host__ __device__ reverse_iterator rbegin () const noexcept
 Reverse iterator for the first element of the array.
constexpr __host__ __device__ reverse_iterator rend () const noexcept
 Reverse iterator for the element after the end of the array.
ArrayRange< pointer > range () const
 Iteration range from the first to the last element.
constexpr __host__ __device__ pointer ptrAt (Int32 index) const
 Address of the index-th element.
constexpr __host__ __device__ reference at (Int32 i) const
constexpr __host__ __device__ void setAt (Int32 i, const_reference value)
__host__ __device__ void fill (T o)
 Fills the array with the value o.
constexpr view_type smallView ()
 Constant view of this view.
constexpr ConstArrayView< value_type > constSmallView () const
 Constant view of this view.
constexpr __host__ __device__ SubSpanType subSpan (Int32 abegin, Int32 asize) const
 Sub-view starting from element abegin and containing asize elements.
constexpr __host__ __device__ SubSpanType subPart (Int32 abegin, Int32 asize) const
 Sub-view starting from element abegin and containing asize elements.
constexpr SubSpanType subView (Int32 abegin, Int32 asize) const
 Sub-view starting from element abegin and containing asize elements.
constexpr __host__ __device__ SubSpanType subspan (Int32 abegin, Int32 asize) const
 For C++20 compatibility.
constexpr SubSpanType subViewInterval (Int32 index, Int32 nb_interval) const
 Sub-view corresponding to the interval index over nb_interval.
constexpr SubSpanType subSpanInterval (Int32 index, Int32 nb_interval) const
 Sub-view corresponding to the interval index over nb_interval.
constexpr SubSpanType subPartInterval (Int32 index, Int32 nb_interval) const
 Sub-view corresponding to the interval index over nb_interval.
__host__ __device__ void copy (const U &copy_array)
 Copies the array copy_array into the instance.
constexpr __host__ __device__ bool empty () const noexcept
 Returns true if the array is empty (zero dimension).
__host__ __device__ bool contains (const_reference v) const
 Returns true if the array contains the element with value v.
std::optional< Int32findFirst (const_reference v) const
constexpr __host__ __device__ void setArray (const ArrayView< T > &v) noexcept
constexpr __host__ __device__ void setArray (const Span< T > &v) noexcept
constexpr __host__ __device__ pointer data () const noexcept
 Pointer to the start of the view.
constexpr __host__ __device__ SpanImpl () noexcept
 Constructs an empty view.
constexpr __host__ __device__ SpanImpl (const SpanImpl< X, Int32, XExtent > &from) noexcept
 Copy constructor from another view.
constexpr __host__ __device__ SpanImpl (const SpanImpl< T, Int32, XExtent > &from) noexcept
constexpr __host__ __device__ SpanImpl (pointer ptr, Int32 asize) noexcept
constexpr __host__ __device__ SpanImpl (std::array< X, N > &from)
 Constructs a view from a std::array.
constexpr __host__ __device__ SpanImpl (T *ptr)
 Constructs a view from a pointer with a fixed size.
constexpr __host__ __device__ ThatClass & operator= (std::array< X, N > &from)
 Copy assignment operator.
constexpr __host__ __device__ reference operator[] (Int32 i) const
 i-th element of the array.
constexpr __host__ __device__ reference operator() (Int32 i) const
 i-th element of the array.
constexpr __host__ __device__ reference item (Int32 i) const
 i-th element of the array.
constexpr __host__ __device__ void setItem (Int32 i, const_reference v) noexcept
 Sets the i-th element of the array.
constexpr __host__ __device__ Int32 size () const noexcept
 Returns the size of the array.
constexpr __host__ __device__ Int32 sizeBytes () const noexcept
 Returns the size of the array in bytes.
constexpr __host__ __device__ Int32 length () const noexcept
 Number of elements in the array.
constexpr __host__ __device__ iterator begin () const noexcept
 Iterator for the first element of the array.
constexpr __host__ __device__ iterator end () const noexcept
 Iterator for the element after the end of the array.
constexpr __host__ __device__ reverse_iterator rbegin () const noexcept
 Reverse iterator for the first element of the array.
constexpr __host__ __device__ reverse_iterator rend () const noexcept
 Reverse iterator for the element after the end of the array.
ArrayRange< pointer > range () const
 Iteration range from the first to the last element.
constexpr __host__ __device__ pointer ptrAt (Int32 index) const
 Address of the index-th element.
constexpr __host__ __device__ reference at (Int32 i) const
constexpr __host__ __device__ void setAt (Int32 i, const_reference value)
__host__ __device__ void fill (T o)
 Fills the array with the value o.
constexpr view_type smallView ()
 Constant view of this view.
constexpr ConstArrayView< value_type > constSmallView () const
 Constant view of this view.
constexpr __host__ __device__ SubSpanType subSpan (Int32 abegin, Int32 asize) const
 Sub-view starting from element abegin and containing asize elements.
constexpr __host__ __device__ SubSpanType subPart (Int32 abegin, Int32 asize) const
 Sub-view starting from element abegin and containing asize elements.
constexpr SubSpanType subView (Int32 abegin, Int32 asize) const
 Sub-view starting from element abegin and containing asize elements.
constexpr __host__ __device__ SubSpanType subspan (Int32 abegin, Int32 asize) const
 For C++20 compatibility.
constexpr SubSpanType subViewInterval (Int32 index, Int32 nb_interval) const
 Sub-view corresponding to the interval index over nb_interval.
constexpr SubSpanType subSpanInterval (Int32 index, Int32 nb_interval) const
 Sub-view corresponding to the interval index over nb_interval.
constexpr SubSpanType subPartInterval (Int32 index, Int32 nb_interval) const
 Sub-view corresponding to the interval index over nb_interval.
__host__ __device__ void copy (const U &copy_array)
 Copies the array copy_array into the instance.
constexpr __host__ __device__ bool empty () const noexcept
 Returns true if the array is empty (zero dimension).
__host__ __device__ bool contains (const_reference v) const
 Returns true if the array contains the element with value v.
std::optional< Int32findFirst (const_reference v) const
constexpr __host__ __device__ void setArray (const ArrayView< T > &v) noexcept
constexpr __host__ __device__ void setArray (const Span< T > &v) noexcept
constexpr __host__ __device__ pointer data () const noexcept
 Pointer to the start of the view.

Static Public Member Functions

static constexpr ThatClass create (pointer ptr, size_type asize) noexcept
 Constructs a view over a memory region starting at ptr and.
Static Public Member Functions inherited from Arcane::SpanImpl< T, Int32, Extent >
static constexpr ThatClass create (pointer ptr, Int32 asize) noexcept
 Constructs a view on a memory region starting at ptr and.
static constexpr ThatClass create (pointer ptr, Int32 asize) noexcept
 Constructs a view on a memory region starting at ptr and.

Static Public Attributes

static constexpr bool IsDynamic = (Extent == DynExtent)
Static Public Attributes inherited from Arcane::SpanImpl< T, Int32, Extent >
static constexpr bool IsDynamic
static constexpr bool IsDynamic

Additional Inherited Members

Protected Member Functions inherited from Arcane::SpanImpl< T, Int32, Extent >
constexpr void _setArray (pointer v, Int32 s) noexcept
 Modifies the array pointer and size.
constexpr void _setPtr (pointer v) noexcept
 Modifies the array start pointer.
constexpr void _setSize (Int32 s) noexcept
 Modifies the array size.
constexpr void _setArray (pointer v, Int32 s) noexcept
 Modifies the array pointer and size.
constexpr void _setPtr (pointer v) noexcept
 Modifies the array start pointer.
constexpr void _setSize (Int32 s) noexcept
 Modifies the array size.

Detailed Description

template<typename T, Int32 Extent>
class Arcane::SmallSpan< T, Extent >

View of an array of elements of type T.

The view is non-modifiable if the template argument is of type 'const T'.

This class allows accessing and using an array of elements of type T in the same way as a standard C array. It is similar to Span, except that the number of elements is stored as an 'Int32'.

Note
To be valid, the number of bytes associated with the view (sizeBytes()) must also fit within an Int32.

Definition at line 803 of file Span.h.

Member Typedef Documentation

◆ BaseClass

template<typename T, Int32 Extent>
using Arcane::SmallSpan< T, Extent >::BaseClass = SpanImpl<T, Int32, Extent>

Definition at line 809 of file Span.h.

◆ is_same_const_type

template<typename T, Int32 Extent>
template<typename X>
using Arcane::SmallSpan< T, Extent >::is_same_const_type = std::enable_if_t<std::is_same_v<X, T> || std::is_same_v<std::add_const_t<X>, T>>

Definition at line 814 of file Span.h.

◆ pointer

template<typename T, Int32 Extent>
using Arcane::SmallSpan< T, Extent >::pointer = typename BaseClass::pointer

Definition at line 812 of file Span.h.

◆ size_type

template<typename T, Int32 Extent>
using Arcane::SmallSpan< T, Extent >::size_type = Int32

Definition at line 810 of file Span.h.

◆ ThatClass

template<typename T, Int32 Extent>
using Arcane::SmallSpan< T, Extent >::ThatClass = SmallSpan<T, Extent>

Definition at line 808 of file Span.h.

◆ value_type

template<typename T, Int32 Extent>
using Arcane::SmallSpan< T, Extent >::value_type = typename BaseClass::value_type

Definition at line 811 of file Span.h.

Constructor & Destructor Documentation

◆ SmallSpan() [1/7]

template<typename T, Int32 Extent>
__host__ __device__ Arcane::SmallSpan< T, Extent >::SmallSpan ( const ArrayView< value_type > & from)
inlineconstexprnoexcept

Copy constructor from another view.

Definition at line 823 of file Span.h.

◆ SmallSpan() [2/7]

template<typename T, Int32 Extent>
template<typename X, typename = std::enable_if_t<std::is_same<X, value_type>::value>>
__host__ __device__ Arcane::SmallSpan< T, Extent >::SmallSpan ( const ConstArrayView< X > & from)
inlineconstexprnoexcept

Definition at line 830 of file Span.h.

◆ SmallSpan() [3/7]

template<typename T, Int32 Extent>
template<typename X, typename = std::enable_if_t<std::is_same<X, value_type>::value>>
__host__ __device__ Arcane::SmallSpan< T, Extent >::SmallSpan ( const SmallSpan< X > & from)
inlineconstexprnoexcept

Definition at line 836 of file Span.h.

◆ SmallSpan() [4/7]

template<typename T, Int32 Extent>
template<Int32 XExtent>
__host__ __device__ Arcane::SmallSpan< T, Extent >::SmallSpan ( const SpanImpl< T, Int32, XExtent > & from)
inlineconstexprnoexcept

Definition at line 841 of file Span.h.

◆ SmallSpan() [5/7]

template<typename T, Int32 Extent>
__host__ __device__ Arcane::SmallSpan< T, Extent >::SmallSpan ( pointer ptr,
Int32 asize )
inlineconstexprnoexcept

Constructs a view over a memory region starting at ptr and containing asize elements.

Definition at line 847 of file Span.h.

◆ SmallSpan() [6/7]

template<typename T, Int32 Extent>
template<std::size_t N, typename X, typename = is_same_const_type<X>>
__host__ __device__ Arcane::SmallSpan< T, Extent >::SmallSpan ( std::array< X, N > & from)
inlineconstexpr

Definition at line 852 of file Span.h.

◆ SmallSpan() [7/7]

template<typename T, Int32 Extent>
__host__ __device__ Arcane::SmallSpan< T, Extent >::SmallSpan ( T * ptr)
inlineexplicitconstexpr

Constructs a view from a pointer with a fixed size.

Definition at line 857 of file Span.h.

Member Function Documentation

◆ create()

template<typename T, Int32 Extent>
constexpr ThatClass Arcane::SmallSpan< T, Extent >::create ( pointer ptr,
size_type asize )
inlinestaticconstexprnoexcept

Constructs a view over a memory region starting at ptr and.

Definition at line 873 of file Span.h.

◆ operator=()

template<typename T, Int32 Extent>
template<std::size_t N, typename X, typename = is_same_const_type<X>>
__host__ __device__ ThatClass & Arcane::SmallSpan< T, Extent >::operator= ( std::array< X, N > & from)
inlineconstexpr

Copy assignment operator.

Definition at line 863 of file Span.h.

◆ subPart()

template<typename T, Int32 Extent>
__host__ __device__ SmallSpan< T, DynExtent > Arcane::SmallSpan< T, Extent >::subPart ( Int32 abegin,
Int32 asize ) const
inlineconstexpr

Sub-view starting from element abegin and containing asize elements.

If (abegin+asize) is greater than the array size, the view is truncated to that size, possibly returning an empty view.

Definition at line 911 of file Span.h.

◆ subPartInterval()

template<typename T, Int32 Extent>
__host__ __device__ ThatClass Arcane::SmallSpan< T, Extent >::subPartInterval ( Int32 index,
Int32 nb_interval ) const
inlineconstexpr

Sub-view corresponding to the interval index over nb_interval.

Definition at line 923 of file Span.h.

◆ subSpan()

template<typename T, Int32 Extent>
__host__ __device__ SmallSpan< T, DynExtent > Arcane::SmallSpan< T, Extent >::subSpan ( Int32 abegin,
Int32 asize ) const
inlineconstexpr

Sub-view starting from element abegin and containing asize elements.

If (abegin+asize) is greater than the array size, the view is truncated to that size, possibly returning an empty view.

Definition at line 899 of file Span.h.

Referenced by Arcane::JaggedSmallSpan< DataType >::operator[]().

◆ subspan()

template<typename T, Int32 Extent>
__host__ __device__ SmallSpan< T, DynExtent > Arcane::SmallSpan< T, Extent >::subspan ( Int32 abegin,
Int32 asize ) const
inlineconstexpr

Sub-view starting from element abegin and containing asize elements.

If (abegin+asize is greater than the array size, the view is truncated to that size, possibly returning an empty view.

Definition at line 887 of file Span.h.

Referenced by Arcane::SmallSpan< Pointer >::subView().

◆ subSpanInterval()

template<typename T, Int32 Extent>
__host__ __device__ SmallSpan< T, DynExtent > Arcane::SmallSpan< T, Extent >::subSpanInterval ( Int32 index,
Int32 nb_interval ) const
inlineconstexpr

Sub-view corresponding to the interval index over nb_interval.

Definition at line 917 of file Span.h.

Referenced by Arcane::SmallSpan< Pointer >::subPartInterval().

◆ subView()

template<typename T, Int32 Extent>
__host__ __device__ SmallSpan< T > Arcane::SmallSpan< T, Extent >::subView ( Int32 abegin,
Int32 asize ) const
inlineconstexpr

Sub-view starting from element abegin and containing asize elements.

If (abegin+asize) is greater than the array size, the view is truncated to that size, possibly returning an empty view.

Definition at line 936 of file Span.h.

◆ subViewInterval()

template<typename T, Int32 Extent>
__host__ __device__ SmallSpan< T > Arcane::SmallSpan< T, Extent >::subViewInterval ( Int32 index,
Int32 nb_interval ) const
inlineconstexpr

Sub-view corresponding to the interval index over nb_interval.

Definition at line 943 of file Span.h.

Member Data Documentation

◆ IsDynamic

template<typename T, Int32 Extent>
bool Arcane::SmallSpan< T, Extent >::IsDynamic = (Extent == DynExtent)
staticconstexpr

Definition at line 815 of file Span.h.


The documentation for this class was generated from the following files: