HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
strided_ptr< T, StrideUnits > Class Template Reference

#include <strided_ptr.h>

Public Member Functions

constexpr strided_ptr (T *ptr=nullptr, ptrdiff_t stride=1) noexcept
 
constexpr strided_ptr (const strided_ptr &p) noexcept
 
const strided_ptroperator= (const strided_ptr &p) noexcept
 
const strided_ptroperator= (T *p) noexcept
 
constexpr Toperator* () const
 
constexpr Toperator[] (ptrdiff_t pos) const
 
constexpr Tdata () const
 
constexpr ptrdiff_t stride () const
 
constexpr bool operator== (const T *p) const
 
constexpr bool operator!= (const T *p) const
 
const strided_ptroperator++ ()
 
const strided_ptr operator++ (int)
 
const strided_ptroperator-- ()
 
const strided_ptr operator-- (int)
 
constexpr strided_ptr operator+ (ptrdiff_t d) const noexcept
 
constexpr strided_ptr operator- (ptrdiff_t d) const noexcept
 
const strided_ptroperator+= (ptrdiff_t d) noexcept
 
const strided_ptroperator-= (ptrdiff_t d)
 

Detailed Description

template<typename T, int StrideUnits = sizeof(T)>
class strided_ptr< T, StrideUnits >

strided_ptr<T> looks like a 'T*', but it incorporates a stride, so it's not limited to adjacent elements. Operators ++, –, [], and so on, take the stride into account when computing where each "array element" actually exists.

A strided_ptr<T> is mutable (the values pointed to may be modified), whereas an strided_ptr<const T> is not mutable.

Fun trick: strided_ptr<T>(&my_value,0) makes a strided_pointer that is addressed like an array, but because the stride is 0, every accessed "element" actually will actually refer to the same value.

By default, if StrideUnits == sizeof(T), then the stride refers to multiples of the size of T. But every once in a while, you need a a byte-addressable stride, and in that case you use a StrideUnits of 1, like: strided_ptr<T,1>.

Definition at line 33 of file strided_ptr.h.

Constructor & Destructor Documentation

template<typename T , int StrideUnits = sizeof(T)>
constexpr strided_ptr< T, StrideUnits >::strided_ptr ( T ptr = nullptr,
ptrdiff_t  stride = 1 
)
inlinenoexcept

Definition at line 35 of file strided_ptr.h.

template<typename T , int StrideUnits = sizeof(T)>
constexpr strided_ptr< T, StrideUnits >::strided_ptr ( const strided_ptr< T, StrideUnits > &  p)
inlinenoexcept

Definition at line 40 of file strided_ptr.h.

Member Function Documentation

template<typename T , int StrideUnits = sizeof(T)>
constexpr T* strided_ptr< T, StrideUnits >::data ( ) const
inline

Definition at line 62 of file strided_ptr.h.

template<typename T , int StrideUnits = sizeof(T)>
constexpr bool strided_ptr< T, StrideUnits >::operator!= ( const T p) const
inline

Definition at line 67 of file strided_ptr.h.

template<typename T , int StrideUnits = sizeof(T)>
constexpr T& strided_ptr< T, StrideUnits >::operator* ( ) const
inline

Definition at line 60 of file strided_ptr.h.

template<typename T , int StrideUnits = sizeof(T)>
constexpr strided_ptr strided_ptr< T, StrideUnits >::operator+ ( ptrdiff_t  d) const
inlinenoexcept

Definition at line 96 of file strided_ptr.h.

template<typename T , int StrideUnits = sizeof(T)>
const strided_ptr& strided_ptr< T, StrideUnits >::operator++ ( )
inline

Definition at line 71 of file strided_ptr.h.

template<typename T , int StrideUnits = sizeof(T)>
const strided_ptr strided_ptr< T, StrideUnits >::operator++ ( int  )
inline

Definition at line 76 of file strided_ptr.h.

template<typename T , int StrideUnits = sizeof(T)>
const strided_ptr& strided_ptr< T, StrideUnits >::operator+= ( ptrdiff_t  d)
inlinenoexcept

Definition at line 104 of file strided_ptr.h.

template<typename T , int StrideUnits = sizeof(T)>
constexpr strided_ptr strided_ptr< T, StrideUnits >::operator- ( ptrdiff_t  d) const
inlinenoexcept

Definition at line 100 of file strided_ptr.h.

template<typename T , int StrideUnits = sizeof(T)>
const strided_ptr& strided_ptr< T, StrideUnits >::operator-- ( )
inline

Definition at line 82 of file strided_ptr.h.

template<typename T , int StrideUnits = sizeof(T)>
const strided_ptr strided_ptr< T, StrideUnits >::operator-- ( int  )
inline

Definition at line 87 of file strided_ptr.h.

template<typename T , int StrideUnits = sizeof(T)>
const strided_ptr& strided_ptr< T, StrideUnits >::operator-= ( ptrdiff_t  d)
inline

Definition at line 109 of file strided_ptr.h.

template<typename T , int StrideUnits = sizeof(T)>
const strided_ptr& strided_ptr< T, StrideUnits >::operator= ( const strided_ptr< T, StrideUnits > &  p)
inlinenoexcept

Definition at line 45 of file strided_ptr.h.

template<typename T , int StrideUnits = sizeof(T)>
const strided_ptr& strided_ptr< T, StrideUnits >::operator= ( T p)
inlinenoexcept

Definition at line 53 of file strided_ptr.h.

template<typename T , int StrideUnits = sizeof(T)>
constexpr bool strided_ptr< T, StrideUnits >::operator== ( const T p) const
inline

Definition at line 66 of file strided_ptr.h.

template<typename T , int StrideUnits = sizeof(T)>
constexpr T& strided_ptr< T, StrideUnits >::operator[] ( ptrdiff_t  pos) const
inline

Definition at line 61 of file strided_ptr.h.

template<typename T , int StrideUnits = sizeof(T)>
constexpr ptrdiff_t strided_ptr< T, StrideUnits >::stride ( ) const
inline

Definition at line 63 of file strided_ptr.h.


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