CUGL 2.0
Cornell University Game Library
Public Member Functions | Static Public Member Functions | List of all members
cugl::Aligned< T > Class Template Reference

#include <CUAligned.h>

Public Member Functions

 Aligned ()
 
 Aligned (size_t size, size_t alignment)
 
 Aligned (const Aligned< T > &copy)
 
 Aligned (Aligned< T > &&other)
 
 ~Aligned ()
 
void dispose ()
 
bool reset (size_t size, size_t alignment)
 
void clear ()
 
size_t size () const
 
Aligned< T > & operator= (const Aligned< T > &copy)
 
Aligned< T > & operator= (Aligned< T > &&other)
 
 operator T* () const
 
Toperator* ()
 
Toperator+ (size_t offset)
 
Toperator[] (size_t idx)
 
const Toperator[] (size_t idx) const
 

Static Public Member Functions

static std::shared_ptr< Aligned< T > > alloc (size_t size, size_t alignment)
 

Detailed Description

template<class T>
class cugl::Aligned< T >

This template provides support for a aligned arrays

Explicit aligned memory allocation is supported in C++17, but not in C++11. As Android can only guarantee C++11, this poses a bit of a problem for Neon and vector optimization. This class presents a workaround that is compatible with C++11.

Constructor & Destructor Documentation

◆ Aligned() [1/4]

template<class T>
cugl::Aligned< T >::Aligned ( )
inline

Creates an empty (nullptr) aligned array.

◆ Aligned() [2/4]

template<class T>
cugl::Aligned< T >::Aligned ( size_t  size,
size_t  alignment 
)
inline

Creates an aligned array of the given size and alignment.

Parameters
sizeThe number of elements in the array
alignmentThe alignment stride

◆ Aligned() [3/4]

template<class T>
cugl::Aligned< T >::Aligned ( const Aligned< T > &  copy)
inline

Creates an (aligned) copy of the given aligned array.

Parameters
copyThe aligned array to copy

◆ Aligned() [4/4]

template<class T>
cugl::Aligned< T >::Aligned ( Aligned< T > &&  other)
inline

Acquires ownership of the contents of an aligned array.

Parameters
otherThe aligned array to move

◆ ~Aligned()

template<class T>
cugl::Aligned< T >::~Aligned ( )
inline

Deletes the given aligned array, releasing all resources.

Member Function Documentation

◆ alloc()

template<class T>
static std::shared_ptr<Aligned<T> > cugl::Aligned< T >::alloc ( size_t  size,
size_t  alignment 
)
inlinestatic

Returns an aligned array of the given size and alignment.

Parameters
sizeThe number of elements in the array
alignmentThe alignment stride
Returns
an aligned array of the given size and alignment.

◆ clear()

template<class T>
void cugl::Aligned< T >::clear ( )
inline

Clears the contents of the given aligned array.

◆ dispose()

template<class T>
void cugl::Aligned< T >::dispose ( )
inline

Disposes the resources of given aligned array, making it a null pointer.

◆ operator T*()

template<class T>
cugl::Aligned< T >::operator T* ( ) const
inline

Returns a pointer to the first element in the array

Returns
a pointer to the first element in the array

◆ operator*()

template<class T>
T& cugl::Aligned< T >::operator* ( )
inline

Returns a reference to the first element in the array

Returns
a reference to the first element in the array

◆ operator+()

template<class T>
T* cugl::Aligned< T >::operator+ ( size_t  offset)
inline

Returns a pointer to the offset element of the array

Parameters
offsetThe array position to access
Returns
a pointer to the offset element of the array

◆ operator=() [1/2]

template<class T>
Aligned<T>& cugl::Aligned< T >::operator= ( Aligned< T > &&  other)
inline

Acquires ownership of the contents of the given aligned array.

Parameters
otherThe aligned array to subsume
Returns
a reference to this aligned array for chaining

◆ operator=() [2/2]

template<class T>
Aligned<T>& cugl::Aligned< T >::operator= ( const Aligned< T > &  copy)
inline

Copies the given aligned array.

Parameters
copyThe aligned array to copy
Returns
a reference to this aligned array for chaining

◆ operator[]() [1/2]

template<class T>
T& cugl::Aligned< T >::operator[] ( size_t  idx)
inline

Returns a reference to the offset element of the array

Parameters
idxThe array position to access
Returns
a reference to the offset element of the array

◆ operator[]() [2/2]

template<class T>
const T& cugl::Aligned< T >::operator[] ( size_t  idx) const
inline

Returns the value of the offset element of the array

Parameters
idxThe array position to access
Returns
the value of the offset element of the array

◆ reset()

template<class T>
bool cugl::Aligned< T >::reset ( size_t  size,
size_t  alignment 
)
inline

Resets an aligned array to an empty one of the given size and alignment.

Parameters
sizeThe number of elements in the array
alignmentThe alignment stride

◆ size()

template<class T>
size_t cugl::Aligned< T >::size ( ) const
inline

Returns the size of this array.

Returns
the size of this array.

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