UCommon
Public Member Functions | Protected Attributes
ucommon::temp_array< T > Class Template Reference

Manage temporary array stored on the heap. More...

#include <generics.h>

Public Member Functions

 operator bool ()
bool operator! ()
T * operator() (size_t offset)
T & operator[] (size_t offset)
void reset (size_t s)
void reset (T &initial, size_t s)
void set (T &initial)
 temp_array (size_t s)
 Construct a temporary object, create our stack frame reference.
 temp_array (T &initial, size_t s)
 Construct a temporary object with a copy of some initial value.
 temp_array (temp_array< T > &)
 Disable copy constructor.

Protected Attributes

T * array
size_t size

Detailed Description

template<typename T>
class ucommon::temp_array< T >

Manage temporary array stored on the heap.

This is used to create an array on the heap who's scope is controlled by the scope of a member function call. Sometimes we have data types and structures which cannot themselves appear as auto variables. We may also have a limited stack frame size in a thread context, and yet have a dynamic object that we only want to exist during the life of the method call. Using temporary allows any type to be created from the heap but have a lifespan of a method's stack frame.

Author:
David Sugar dyfet.nosp@m.@gnu.nosp@m.telep.nosp@m.hony.nosp@m..org

Definition at line 346 of file generics.h.


Constructor & Destructor Documentation

template<typename T >
ucommon::temp_array< T >::temp_array ( T &  initial,
size_t  s 
) [inline]

Construct a temporary object with a copy of some initial value.

Parameters:
initialobject value to use.

Definition at line 363 of file generics.h.


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