geomc 1.0
A c++ linear algebra template library
Loading...
Searching...
No Matches
GenericStorage< T, N, P > Struct Template Reference

Array storage with templated static or dynamic size, and template-selectable ownership policy. More...

#include <geomc/Storage.h>

Public Types

typedef Storage< T, N > type
 Storage class inherited from.
 

Public Member Functions

 GenericStorage (index_t n)
 Construct a new array of size n. Not available for wrapped specializations.
 
 GenericStorage (index_t n, T *srcdata)
 Construct a new array of size n, initialized with srcdata.
 
 GenericStorage (std::initializer_list< T > list)
 
T * get ()
 Return a pointer to the first element in the storage array.
 
const T * get () const
 Return a const pointer to the first element in the storage array.
 
T & operator[] (index_t idx)
 Return a reference to the ith element in the array.
 
operator[] (index_t idx) const
 Return the ith element in the array.
 
index_t size () const
 Return the number of elements in the array.
 

Detailed Description

template<typename T, index_t N, StoragePolicy P>
struct geom::GenericStorage< T, N, P >

Array storage with templated static or dynamic size, and template-selectable ownership policy.

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

The ownership policy behavior is as follows:

  • If the ownership policy is STORAGE_SHARED, then dynamically-sized arrays will allocate their own reference-counted memory, and the underlying storage will be deleted when the last owner is destroyed.
  • If the ownership policy is STORAGE_UNIQUE, then dynamically-sized arrays will allocate their own memory, and the underlying arrays will be duplicated on copy or assignment.
  • If the ownership is STORAGE_WRAPPED, then the array will simply wrap a pointer to caller-managed memory, which must be valid for the lifetime of this object, and must contain the minimum number of elements. Duplicates will refer to the same backing memory. No attempt will be made to free the pointer upon destruction.

#include <geomc/Storage.h>


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