Evo C++ Library v0.5.1
Public Types | Static Public Member Functions | List of all members
DataInit< T, U > Struct Template Reference

#include <evo/impl/container.h>

Inheritance diagram for DataInit< T, U >:
Inheritance graph
[legend]

Detailed Description

template<class T, class U = typename TypeId::Get<T>::Id>
struct evo::DataInit< T, U >

Optimized data initialization and uninitialization helpers.

Template Parameters
TData type to use
UInferred from T

Public Types

typedef RemoveConst< T >::Type Item
 Item type (const removed) More...
 

Static Public Member Functions

static void copy (Item *dest, const Item *src, ulong size)
 Copy already initialized data (assignment operator). More...
 
static void init (Item *data, ulong size=1)
 Initialize data using default constructor. More...
 
static void init (Item *data, const Item *src, ulong count)
 Initialize data using copy constructor. More...
 
static void init (Item *data, ulong size, const Item *src, ulong count)
 Initialize data using copy constructor and default constructor. More...
 
static void init_safe (Item *data, ulong size=1)
 Initialize data using default constructor. More...
 
static void init_safe (Item *data, ulong size, const Item *src, ulong count)
 Initialize data using copy constructor and default constructor. More...
 
static void init_tail_fast (Item *data, ulong oldSize, ulong newSize)
 Initialize new tail data (default constructor). More...
 
static void init_tail_safe (Item *data, ulong oldSize, ulong newSize)
 Initialize new tail data (default constructor). More...
 
static void initcopy (Item *item, const Item *src)
 Initialize new item as copy of src (copy constructor). More...
 
static void uninit (Item *data, ulong size)
 Uninitialize data (destructor). More...
 
static void uninit_free_ptr (Item **data, ulong size)
 Uninitialize and free array of pointers (destructor). More...
 
static void uninit_tail (Item *data, ulong oldSize, ulong newSize)
 Uninitialize old tail data (destructor). More...
 

Member Typedef Documentation

◆ Item

typedef RemoveConst<T>::Type Item
inherited

Item type (const removed)

Member Function Documentation

◆ copy()

static void copy ( Item dest,
const Item src,
ulong  size 
)
inlinestatic

Copy already initialized data (assignment operator).

Parameters
destDestination data pointer - must be valid
srcSource data pointer - must be valid
sizeCopy size - must be positive

◆ init() [1/3]

static void init ( Item data,
ulong  size = 1 
)
inlinestatic

Initialize data using default constructor.

  • Same as init_safe() except will not initialize new POD values, so is faster for POD types
Parameters
dataData pointer - must be valid
sizeData size - must be positive

◆ init() [2/3]

static void init ( Item data,
const Item src,
ulong  count 
)
inlinestatic

Initialize data using copy constructor.

Parameters
dataData pointer - must be valid
srcSource data to copy - must be valid
countNumber of items to copy - must be positive

◆ init() [3/3]

static void init ( Item data,
ulong  size,
const Item src,
ulong  count 
)
inlinestatic

Initialize data using copy constructor and default constructor.

Parameters
dataData pointer - must be valid
sizeData size - must be positive
srcSource data to copy - must be valid
countNumber of items to copy - must be positive

◆ init_safe() [1/2]

static void init_safe ( Item data,
ulong  size = 1 
)
inlinestatic

Initialize data using default constructor.

  • Same as init(T*,ulong) except will initialize new POD values to 0, so is safer but slower for POD types
Parameters
dataData pointer - must be valid
sizeData size - must be positive

◆ init_safe() [2/2]

static void init_safe ( Item data,
ulong  size,
const Item src,
ulong  count 
)
inlinestatic

Initialize data using copy constructor and default constructor.

Parameters
dataData pointer - must be valid
sizeData size - must be positive
srcSource data to copy - must be valid
countNumber of items to copy - must be positive

◆ init_tail_fast()

static void init_tail_fast ( Item data,
ulong  oldSize,
ulong  newSize 
)
inlinestatic

Initialize new tail data (default constructor).

  • This is usefull for growing an array and initializes new data when newSize is greater than oldSize
  • Same as init_tail_safe() except will not initialize new POD values, so is faster for POD types
Parameters
dataData pointer - must be valid
oldSizeOld data size that is already initialized
newSizeNew data size that will need data initialized if larger

◆ init_tail_safe()

static void init_tail_safe ( Item data,
ulong  oldSize,
ulong  newSize 
)
inlinestatic

Initialize new tail data (default constructor).

  • This is usefull for growing an array and initializes new data when newSize is greater than oldSize
  • Same as init_tail_fast() except will initialize new POD values to 0, so is safer but slower for POD types
Parameters
dataData pointer - must be valid
oldSizeOld data size that is already initialized
newSizeNew data size that will need data initialized if larger

◆ initcopy()

static void initcopy ( Item item,
const Item src 
)
inlinestatic

Initialize new item as copy of src (copy constructor).

Parameters
itemItem to initialize
srcSource to copy

◆ uninit()

static void uninit ( Item data,
ulong  size 
)
inlinestatic

Uninitialize data (destructor).

Parameters
dataData pointer - must be valid
sizeSize of data

◆ uninit_free_ptr()

static void uninit_free_ptr ( Item **  data,
ulong  size 
)
inlinestatic

Uninitialize and free array of pointers (destructor).

  • Skips null pointers
Parameters
dataData pointer - must be valid
sizeSize of data

◆ uninit_tail()

static void uninit_tail ( Item data,
ulong  oldSize,
ulong  newSize 
)
inlinestatic

Uninitialize old tail data (destructor).

  • This is usefull for shrinking an array and uninitializing old data when newSize is less than oldSize
Parameters
dataData pointer - must be valid
oldSizeOld data size that is already initialized
newSizeNew data size that will need data uninitialized if smaller

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