SPH
Public Types | Public Member Functions | Friends | List of all members
ArrayView< T, TCounter > Class Template Reference

Object providing safe access to continuous memory of data. More...

#include <ArrayView.h>

Public Types

using Type = T
 
using Counter = TCounter
 

Public Member Functions

INLINE ArrayView ()
 
INLINE ArrayView (StorageType *data, TCounter size)
 
INLINE ArrayView (const ArrayView &other)
 
INLINE ArrayView (std::nullptr_t)
 Explicitly initialize to nullptr. More...
 
INLINE ArrayViewoperator= (const ArrayView &other)
 Copy operator. More...
 
INLINE operator ArrayView< const T, TCounter > () const
 Implicit conversion to const version. More...
 
INLINE Iterator< StorageType > begin ()
 
INLINE Iterator< const StorageType > begin () const
 
INLINE Iterator< StorageType > end ()
 
INLINE Iterator< const StorageType > end () const
 
INLINE T & operator[] (const TCounter idx)
 
INLINE const T & operator[] (const TCounter idx) const
 
INLINE T & front ()
 
INLINE const T & front () const
 
INLINE T & back ()
 
INLINE const T & back () const
 
INLINE TCounter size () const
 
INLINE bool empty () const
 
INLINE ArrayView subset (const TCounter start, const TCounter length) const
 Returns a subset of the arrayview. More...
 
INLINE bool operator! () const
 
INLINE operator bool () const
 
bool operator== (const ArrayView &other) const
 Comparison operator, comparing arrayviews element-by-element. More...
 
bool operator!= (const ArrayView &other) const
 Inequality operator. More...
 

Friends

std::ostream & operator<< (std::ostream &stream, const ArrayView &array)
 Prints content of arrayview to stream. More...
 

Detailed Description

template<typename T, typename TCounter = Size>
class ArrayView< T, TCounter >

Object providing safe access to continuous memory of data.

Useful to write generic code that can be used with any kind of storage where the data are stored consecutively in memory. Commonly used containers are implicitly convertible to ArrayView.

Definition at line 17 of file ArrayView.h.

Member Typedef Documentation

◆ Counter

template<typename T , typename TCounter = Size>
using ArrayView< T, TCounter >::Counter = TCounter

Definition at line 26 of file ArrayView.h.

◆ Type

template<typename T , typename TCounter = Size>
using ArrayView< T, TCounter >::Type = T

Definition at line 25 of file ArrayView.h.

Constructor & Destructor Documentation

◆ ArrayView() [1/4]

template<typename T , typename TCounter = Size>
INLINE ArrayView< T, TCounter >::ArrayView ( )
inline

Definition at line 28 of file ArrayView.h.

◆ ArrayView() [2/4]

template<typename T , typename TCounter = Size>
INLINE ArrayView< T, TCounter >::ArrayView ( StorageType *  data,
TCounter  size 
)
inline

Definition at line 31 of file ArrayView.h.

◆ ArrayView() [3/4]

template<typename T , typename TCounter = Size>
INLINE ArrayView< T, TCounter >::ArrayView ( const ArrayView< T, TCounter > &  other)
inline

Definition at line 35 of file ArrayView.h.

◆ ArrayView() [4/4]

template<typename T , typename TCounter = Size>
INLINE ArrayView< T, TCounter >::ArrayView ( std::nullptr_t  )
inline

Explicitly initialize to nullptr.

Definition at line 40 of file ArrayView.h.

Member Function Documentation

◆ back() [1/2]

template<typename T , typename TCounter = Size>
INLINE T& ArrayView< T, TCounter >::back ( )
inline

Definition at line 91 of file ArrayView.h.

◆ back() [2/2]

template<typename T , typename TCounter = Size>
INLINE const T& ArrayView< T, TCounter >::back ( ) const
inline

Definition at line 96 of file ArrayView.h.

◆ begin() [1/2]

template<typename T , typename TCounter = Size>
INLINE Iterator<StorageType> ArrayView< T, TCounter >::begin ( )
inline

Definition at line 55 of file ArrayView.h.

◆ begin() [2/2]

template<typename T , typename TCounter = Size>
INLINE Iterator<const StorageType> ArrayView< T, TCounter >::begin ( ) const
inline

Definition at line 59 of file ArrayView.h.

◆ empty()

template<typename T , typename TCounter = Size>
INLINE bool ArrayView< T, TCounter >::empty ( ) const
inline

Definition at line 105 of file ArrayView.h.

◆ end() [1/2]

template<typename T , typename TCounter = Size>
INLINE Iterator<StorageType> ArrayView< T, TCounter >::end ( )
inline

Definition at line 63 of file ArrayView.h.

◆ end() [2/2]

template<typename T , typename TCounter = Size>
INLINE Iterator<const StorageType> ArrayView< T, TCounter >::end ( ) const
inline

Definition at line 67 of file ArrayView.h.

◆ front() [1/2]

template<typename T , typename TCounter = Size>
INLINE T& ArrayView< T, TCounter >::front ( )
inline

Definition at line 81 of file ArrayView.h.

◆ front() [2/2]

template<typename T , typename TCounter = Size>
INLINE const T& ArrayView< T, TCounter >::front ( ) const
inline

Definition at line 86 of file ArrayView.h.

◆ operator ArrayView< const T, TCounter >()

template<typename T , typename TCounter = Size>
INLINE ArrayView< T, TCounter >::operator ArrayView< const T, TCounter > ( ) const
inline

Implicit conversion to const version.

Definition at line 51 of file ArrayView.h.

◆ operator bool()

template<typename T , typename TCounter = Size>
INLINE ArrayView< T, TCounter >::operator bool ( ) const
inlineexplicit

Definition at line 119 of file ArrayView.h.

◆ operator!()

template<typename T , typename TCounter = Size>
INLINE bool ArrayView< T, TCounter >::operator! ( ) const
inline

Definition at line 115 of file ArrayView.h.

◆ operator!=()

template<typename T , typename TCounter = Size>
bool ArrayView< T, TCounter >::operator!= ( const ArrayView< T, TCounter > &  other) const
inline

Inequality operator.

Definition at line 137 of file ArrayView.h.

◆ operator=()

template<typename T , typename TCounter = Size>
INLINE ArrayView& ArrayView< T, TCounter >::operator= ( const ArrayView< T, TCounter > &  other)
inline

Copy operator.

Definition at line 44 of file ArrayView.h.

◆ operator==()

template<typename T , typename TCounter = Size>
bool ArrayView< T, TCounter >::operator== ( const ArrayView< T, TCounter > &  other) const
inline

Comparison operator, comparing arrayviews element-by-element.

Definition at line 124 of file ArrayView.h.

◆ operator[]() [1/2]

template<typename T , typename TCounter = Size>
INLINE T& ArrayView< T, TCounter >::operator[] ( const TCounter  idx)
inline

Definition at line 71 of file ArrayView.h.

◆ operator[]() [2/2]

template<typename T , typename TCounter = Size>
INLINE const T& ArrayView< T, TCounter >::operator[] ( const TCounter  idx) const
inline

Definition at line 76 of file ArrayView.h.

◆ size()

template<typename T , typename TCounter = Size>
INLINE TCounter ArrayView< T, TCounter >::size ( ) const
inline

Definition at line 101 of file ArrayView.h.

◆ subset()

template<typename T , typename TCounter = Size>
INLINE ArrayView ArrayView< T, TCounter >::subset ( const TCounter  start,
const TCounter  length 
) const
inline

Returns a subset of the arrayview.

Definition at line 110 of file ArrayView.h.

Friends And Related Function Documentation

◆ operator<<

template<typename T , typename TCounter = Size>
std::ostream& operator<< ( std::ostream &  stream,
const ArrayView< T, TCounter > &  array 
)
friend

Prints content of arrayview to stream.

Stored values must have overloaded << operator.

Definition at line 144 of file ArrayView.h.


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