Rudiments: staticarray< valuetype, length > Class Template Reference

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>

staticarray< valuetype, length >::staticarray
| inline

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>

staticarray< valuetype, length >::staticarray | ( | const staticarray< valuetype, length > & | v | ) |
| inline

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

## ◆ ~staticarray()

template<class valuetype , uint64_t length>

staticarray< valuetype, length >::~staticarray
| inline

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

## Member Function Documentation

## ◆ clear()

template<class valuetype , uint64_t length>

void staticarray< valuetype, length >::clear
| inline

Clears the array, deleting all of its values.

## ◆ getLength()

template<class valuetype , uint64_t length>

uint64_t staticarray< valuetype, length >::getLength
| inline

Returns the number of elements in the array.

## ◆ operator=()

template<class valuetype , uint64_t length>

staticarray< valuetype, length > & staticarray< valuetype, length >::operator= | ( | const staticarray< valuetype, length > & | v | ) |
| inline

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

## ◆ operator[]()

template<class valuetype , uint64_t length>

valuetype & staticarray< valuetype, length >::operator[] | ( | uint64_t | index | ) |
| inline

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