![]() |
VISR
0.11.8
Versatile Interactive Scene Renderer
|
#include <aligned_array.hpp>
Public Member Functions | |
AlignedArray (std::size_t alignmentElements) | |
AlignedArray (std::size_t length, std::size_t alignmentElements) | |
AlignedArray (AlignedArray< ElementType > &&rhs) | |
AlignedArray< ElementType > & | operator= (AlignedArray< ElementType > &&rhs) |
~AlignedArray () | |
void | resize (std::size_t newLength) |
void | swap (AlignedArray< ElementType > &rhs) |
std::size_t | size () const |
std::size_t | alignmentElements () const |
std::size_t | alignmentBytes () const |
ElementType * | data () |
ElementType const * | data () const |
ElementType & | operator[] (std::size_t index) |
ElementType const & | operator[] (std::size_t index) const |
ElementType & | at (std::size_t index) |
ElementType const & | at (std::size_t index) const |
A template class to provide memory that is aligned in memory. Alignment is an important property for speed. The aligement is given as a number of elements. This means that the pointer to the aligned memory is divisable by alignmentElements*sizeof(T) .
ElementType | The type of the array elements |
|
explicit |
Constructor, constructs an empty array and sets the alignment. Note that this array cannot be dereferenced, and data() returns a null pointer.
alignmentElements | The requested alignment of the array which will be used if the array is resized to a non-zero length. The alignment must be a one or an integral power of two. A value of zero is supported, but transformed to 2 internally. |
std::invalid_argument | If the alignment value is not an integer power of 2 (or 0 or 1) |
|
explicit |
Constructor, create an array with a specified number of elements and the given alignment.
length | The requested length of the array, given as number of elements. |
alignmentElements | The requested alignment of the array. The alignment must be a one or an integral power of two. A value of zero is supported, but transformed to 2 internally. |
std::invalid_argument | If the alignment value is not an integer power of 2 (or 0 or 1) |
visr::efl::AlignedArray< ElementType >::AlignedArray | ( | AlignedArray< ElementType > && | rhs | ) |
Move constructor, takes over the contents of an rvalue rhs
and leaves rhs
in an empty, but valid state.
visr::efl::AlignedArray< ElementType >::~AlignedArray | ( | ) |
|
inline |
Return the alignment of the the data structure (measured in bytes) as determined in the constructor.
|
inline |
Return the alignment of the the data structure (measured in number of elements) as determined in the constructor.
|
inline |
Indexed access, return a modifiable reference to the element addressed by index. The function variant provides range checking.
index | Zero-offset index into the array |
std::out_of_range | if index exceeds the allocated length of the array. |
|
inline |
Indexed access, return a constant reference to the element addressed by index. The function variant provides range checking.
index | Zero-offset index into the array |
std::out_of_range | if index exceeds the allocated length of the array. |
|
inline |
Return a writable pointer to the data elements.
|
inline |
Return a constant pointer to the data elements.
AlignedArray< ElementType > & visr::efl::AlignedArray< ElementType >::operator= | ( | AlignedArray< ElementType > && | rhs | ) |
Move assignment operator from a rvalue rhs
.
rhs
must match the alignment of this object. std::logic_error | if the alignment of rhs does not match this object. |
|
inline |
Indexed access, return a modifiable reference to the element addressed by index.
index | Zero-offset index into the array |
|
inline |
Indexed access, return a constant reference to the element addressed by index.
index | Zero-offset index into the array |
void visr::efl::AlignedArray< ElementType >::resize | ( | std::size_t | newLength | ) |
Change the number of elements in the array. The old content of the array is not retained, but the new content is initialized with arbitrary values.
newLength | The allocated length of the array (in bytes) |
|
inline |
Return the size of the array (in elements). This value may differ from the allocated length in order to ensure the prescribed alignment.
void visr::efl::AlignedArray< ElementType >::swap | ( | AlignedArray< ElementType > & | rhs | ) |
Exchange the contents of this object with that of rhs. Does not throw, thus enabling exception safety for classes using AlignedArray.
Swap the content with another AlignedArray object. This method has strong exception safety and does not involve memory allocation or vector copy operations.
rhs | The object to be swapped with. |
std::logic_error | If the objects do not have the same alignment. |