ArrayHelper< T, isTrivial > Struct Template Reference

This is a helper template struct for ArrayData's constructors. More...

#include <Image/ArrayData.H>

List of all members.

Static Public Member Functions

static void minimal_initialize (T *trg, int n)
 Construct n copies of val at space using placement new.
static void minimal_initialize (T *trg, int n, const MemoryPolicy mp, const int dev)
static void zero_initialize (T *trg, int n)
 Initialize the memory to T's default or zero value.
static void zero_initialize (T *trg, int n, const MemoryPolicy mp, const int dev)
static void copy_initialize (T *trg, int n, const T *src)
 Initialize the memory by copying elements from the src array.
static void copy_initialize (T *trg, int n, const T *src, const MemoryPolicy trgmp, const int trgdev, const MemoryPolicy srcmp, const int srcdev)
static void destruct (T *trg, int n)
 Call destructors on the n objects stored in space.
static void destruct (T *trg, int n, const MemoryPolicy mp, const int dev)

Detailed Description

template<class T, bool isTrivial = TypeTraits<T>::isTrivial>
struct ArrayHelper< T, isTrivial >

This is a helper template struct for ArrayData's constructors.

It exposes functions for initializing raw memory in different ways. These functions can then be specialized for builtin or trivial types (i.e., types for which TypeTraits<T>::isTrivial is true) for maximum efficiency. We get this specialization by having an extra bool isTrivial template parameter for ArrayHelper, which allows us to select at compile-time based on the complexity of T. This is much better than using a run-time "if" statement in the constructors, since that incurs both a time cost (to evaluate an "if" statement) and a code space cost (since we're then including code that won't be used).

Definition at line 403 of file ArrayData.H.


Member Function Documentation

template<class T, bool isTrivial = TypeTraits<T>::isTrivial>
static void ArrayHelper< T, isTrivial >::copy_initialize ( T *  trg,
int  n,
const T *  src 
) [inline, static]

Initialize the memory by copying elements from the src array.

For general types, we just copy construct each element in the target array from the corresponding element in the src array, using placement new.

Definition at line 470 of file ArrayData.H.

References invt_deallocate().

template<class T, bool isTrivial = TypeTraits<T>::isTrivial>
static void ArrayHelper< T, isTrivial >::destruct ( T *  trg,
int  n 
) [inline, static]

Call destructors on the n objects stored in space.

Definition at line 542 of file ArrayData.H.

template<class T, bool isTrivial = TypeTraits<T>::isTrivial>
static void ArrayHelper< T, isTrivial >::minimal_initialize ( T *  trg,
int  n 
) [inline, static]

Construct n copies of val at space using placement new.

For general types, the minimal initialization that we can do is to zero_initialize() (i.e., unlike for builtin or trivial types, we can't just leave the memory sitting as it is, uninitialized).

Definition at line 410 of file ArrayData.H.

References ArrayHelper< T, isTrivial >::zero_initialize().

template<class T, bool isTrivial = TypeTraits<T>::isTrivial>
static void ArrayHelper< T, isTrivial >::zero_initialize ( T *  trg,
int  n 
) [inline, static]

Initialize the memory to T's default or zero value.

For general types, the best way to do this is to make one default T object, and then copy construct each element of the array from that object using placement new.

Definition at line 424 of file ArrayData.H.

References invt_deallocate().

Referenced by ArrayHelper< T, isTrivial >::minimal_initialize().


The documentation for this struct was generated from the following file:
Generated on Sun May 8 08:43:06 2011 for iLab Neuromorphic Vision Toolkit by  doxygen 1.6.3