geomc 1.0
A c++ linear algebra template library
Public Member Functions | Public Attributes | List of all members
Storage< T, N > Struct Template Reference

Array storage with templated static or dynamic size. More...

#include <geomc/Storage.h>

Inheritance diagram for Storage< T, N >:
SizedStorage< T, N >

Public Member Functions

 Storage ()
 Construct a new storage array of length N (Static size only).
 
 Storage (index_t n)
 Construct a new storage array of length n. n is ignored if the array size is not dynamic.
 
 Storage (index_t n, const T *srcdata)
 Construct a new storage array of length n and fill with n elements from srcdata.
 
 Storage (const T *srcdata)
 Construct a new storage array and fill with N elements from srcdata (static size only).
 
T * get ()
 Return a pointer to the first element in the storage array.
 
const T * get () const
 Return a pointer to the first (const) element in the storage array.
 
index_t size () const
 Return the number of elements in the array. (Static size only).
 
T & operator[] (index_t i)
 Return a reference to the ith element in the array.
 
operator[] (index_t i) const
 Return the ith element in the array.
 

Public Attributes

data [N]
 Data array. Reference-counted if N is 0 (dynamic).
 

Detailed Description

template<typename T, index_t N>
struct geom::Storage< T, N >

Array storage with templated static or dynamic size.

Template Parameters
TElement type.
NSize of the array, or 0 for dynamic size.

The array will be dynamically allocated if the dimension template argument N is zero; otherwise the storage will be local. Dynamically allocated storage uses reference counting for memory management.

This is the simplest type of storage, in which the client is responsible for keeping track of the size of dynamic arrays. (This may save space particularly if multiple/parallel Storage arrays are in use).

#include <geomc/Storage.h>


The documentation for this struct was generated from the following files: