Rudiments
Public Member Functions | List of all members
staticarray< valuetype, length > Class Template Reference

Public Member Functions

 staticarray ()
 
 staticarray (const staticarray< valuetype, length > &v)
 
staticarray< valuetype, length > & operator= (const staticarray< valuetype, length > &v)
 
 ~staticarray ()
 
valuetype & operator[] (uint64_t index)
 
uint64_t getLength () const
 
void clear ()
 

Detailed Description

template<class valuetype, uint64_t length>
class staticarray< valuetype, length >

The staticarray class allows you to store a pre-defined number of values and access them with array-like syntax.

"valuetype" can be any scalar type, including a pointer, but cannot be an array.

Ie. these are legal: staticarray< int, 10 > d; staticarray< myclass, 10 > d; staticarray< myclass *, 10 > d;

These are not legal and whether they work or even compile would be platform-dependent: staticarray< int[100], 10 > d; staticarray< myclass[100], 10 > d; staticarray< myclass *[100], 10 > d;

However, it is possible to create an array of arrays by nesting staticarrays or dynamicarrays, like:

staticarray< staticarray< int >, 10 > d;
staticarray< staticarray< myclass >, 10 > d;
staticarray< staticarray< myclass * >, 10 > d;
staticarray< dynamicarray< int >, 10 > d;
staticarray< dynamicarray< myclass >, 10 > d;
staticarray< dynamicarray< myclass * >, 10 > d;

Constructor & Destructor Documentation

◆ staticarray() [1/2]

template<class valuetype , uint64_t length>
RUDIMENTS_TEMPLATE_INLINE staticarray< valuetype, length >::staticarray ( )

Creates an empty instance of the staticarray class with "length" elements. "length" is given in the template definition.

◆ staticarray() [2/2]

template<class valuetype , uint64_t length>
RUDIMENTS_TEMPLATE_INLINE staticarray< valuetype, length >::staticarray ( const staticarray< valuetype, length > &  v)

Creates an instance of the staticarray class that is a copy of "v".

◆ ~staticarray()

template<class valuetype , uint64_t length>
RUDIMENTS_TEMPLATE_INLINE staticarray< valuetype, length >::~staticarray ( )

Deletes this instance of the staticarray class and all of its values.

Member Function Documentation

◆ clear()

template<class valuetype , uint64_t length>
RUDIMENTS_TEMPLATE_INLINE void staticarray< valuetype, length >::clear ( )

Clears the array, deleting all of its values.

◆ getLength()

template<class valuetype , uint64_t length>
RUDIMENTS_TEMPLATE_INLINE uint64_t staticarray< valuetype, length >::getLength ( ) const

Returns the length of the array.

◆ operator=()

template<class valuetype , uint64_t length>
RUDIMENTS_TEMPLATE_INLINE staticarray< valuetype, length > & staticarray< valuetype, length >::operator= ( const staticarray< valuetype, length > &  v)

Makes this instance of the staticarray class identical to "v".

◆ operator[]()

template<class valuetype , uint64_t length>
RUDIMENTS_TEMPLATE_INLINE valuetype & staticarray< valuetype, length >::operator[] ( uint64_t  index)

Provides access to the "index"th element of the staticarray.