ezEngine  Milestone 9
ezArrayPtr< T > Class Template Reference

This class encapsulates an array and it's size. It is recommended to use this class instead of plain C arrays. More...

#include <ArrayPtr.h>

Public Types

typedef T ElementType
 
typedef ezTypeTraits< T >::NonConstType MutableElementType
 
typedef ezArrayPtrDetail::ByteTypeHelper< T >::type ByteType
 
typedef ezArrayPtrDetail::VoidTypeHelper< T >::valueType ValueType
 
typedef ezArrayPtrDetail::VoidTypeHelper< T >::pointerType PointerType
 
typedef const T * const_iterator
 
typedef const_reverse_pointer_iterator< T > const_reverse_iterator
 
typedef T * iterator
 
typedef reverse_pointer_iterator< T > reverse_iterator
 

Public Member Functions

 EZ_DECLARE_POD_TYPE ()
 
EZ_ALWAYS_INLINE ezArrayPtr ()
 Initializes the ezArrayPtr to be empty.
 
template<typename U , typename = std::enable_if_t<!std::is_same<std::remove_cv_t<T>, void>::value || sizeof(typename ezArrayPtrDetail::VoidTypeHelper<U>::valueType) == 1>>
 ezArrayPtr (U *ptr, ezUInt32 uiCount)
 Initializes the ezArrayPtr with the given pointer and number of elements. No memory is allocated or copied. More...
 
template<size_t N>
EZ_ALWAYS_INLINE ezArrayPtr (ValueType(&staticArray)[N])
 Initializes the ezArrayPtr to encapsulate the given array.
 
EZ_ALWAYS_INLINE ezArrayPtr (const ezArrayPtr< T > &other)
 Initializes the ezArrayPtr to be a copy of other. No memory is allocated or copied.
 
 operator ezArrayPtr< const T > () const
 Convert to const version.
 
EZ_ALWAYS_INLINE void operator= (const ezArrayPtr< T > &other)
 Copies the pointer and size of /a other. Does not allocate any data.
 
EZ_ALWAYS_INLINE void Clear ()
 Clears the array.
 
EZ_ALWAYS_INLINE void operator= (std::nullptr_t)
 
EZ_ALWAYS_INLINE const PointerType GetPtr () const
 Returns the pointer to the array.
 
EZ_ALWAYS_INLINE PointerType GetPtr ()
 Returns the pointer to the array.
 
EZ_ALWAYS_INLINE PointerType GetEndPtr ()
 Returns the pointer behind the last element of the array.
 
EZ_ALWAYS_INLINE const PointerType GetEndPtr () const
 Returns the pointer behind the last element of the array.
 
EZ_ALWAYS_INLINE bool IsEmpty () const
 Returns whether the array is empty.
 
EZ_ALWAYS_INLINE ezUInt32 GetCount () const
 Returns the number of elements in the array.
 
EZ_FORCE_INLINE ezArrayPtr< const T > GetSubArray (ezUInt32 uiStart, ezUInt32 uiCount) const
 Creates a sub-array from this array.
 
EZ_FORCE_INLINE ezArrayPtr< T > GetSubArray (ezUInt32 uiStart, ezUInt32 uiCount)
 Creates a sub-array from this array.
 
EZ_FORCE_INLINE ezArrayPtr< const T > GetSubArray (ezUInt32 uiStart) const
 Creates a sub-array from this array. More...
 
EZ_FORCE_INLINE ezArrayPtr< T > GetSubArray (ezUInt32 uiStart)
 Creates a sub-array from this array. More...
 
EZ_ALWAYS_INLINE ezArrayPtr< const ByteType > ToByteArray () const
 Reinterprets this array as a byte array.
 
EZ_ALWAYS_INLINE ezArrayPtr< ByteType > ToByteArray ()
 Reinterprets this array as a byte array.
 
template<typename U >
EZ_ALWAYS_INLINE ezArrayPtr< U > Cast ()
 Cast an ArrayPtr to an ArrayPtr to a different, but same size, type.
 
template<typename U >
EZ_ALWAYS_INLINE ezArrayPtr< const U > Cast () const
 Cast an ArrayPtr to an ArrayPtr to a different, but same size, type.
 
EZ_FORCE_INLINE const ValueType & operator[] (ezUInt32 uiIndex) const
 Index access.
 
EZ_FORCE_INLINE ValueType & operator[] (ezUInt32 uiIndex)
 Index access.
 
bool operator== (const ezArrayPtr< const T > &other) const
 Compares the two arrays for equality.
 
EZ_ALWAYS_INLINE bool operator!= (const ezArrayPtr< const T > &other) const
 Compares the two arrays for inequality.
 
void CopyFrom (const ezArrayPtr< const T > &other)
 Copies the data from other into this array. The arrays must have the exact same size.
 
EZ_ALWAYS_INLINE void Swap (ezArrayPtr< T > &other)
 

Detailed Description

template<typename T>
class ezArrayPtr< T >

This class encapsulates an array and it's size. It is recommended to use this class instead of plain C arrays.

No data is deallocated at destruction, the ezArrayPtr only allows for easier access.

Constructor & Destructor Documentation

◆ ezArrayPtr()

template<typename T>
template<typename U , typename = std::enable_if_t<!std::is_same<std::remove_cv_t<T>, void>::value || sizeof(typename ezArrayPtrDetail::VoidTypeHelper<U>::valueType) == 1>>
ezArrayPtr< T >::ezArrayPtr ( U *  ptr,
ezUInt32  uiCount 
)
inline

Initializes the ezArrayPtr with the given pointer and number of elements. No memory is allocated or copied.

Note
For ArrayPtr<void> and ArrayPtr<const void>, this constructor is only available if ptr is of type void*, const void*, or any T* with sizeof(T) == 1

Member Function Documentation

◆ GetSubArray() [1/2]

template<typename T>
EZ_FORCE_INLINE ezArrayPtr<const T> ezArrayPtr< T >::GetSubArray ( ezUInt32  uiStart) const
inline

Creates a sub-array from this array.

Note
ap.GetSubArray(i)
is equivalent to
ap.GetSubArray(i, ap.GetCount() - i)
.

◆ GetSubArray() [2/2]

template<typename T>
EZ_FORCE_INLINE ezArrayPtr<T> ezArrayPtr< T >::GetSubArray ( ezUInt32  uiStart)
inline

Creates a sub-array from this array.

Note
ap.GetSubArray(i)
is equivalent to
ap.GetSubArray(i, ap.GetCount() - i)
.

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