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

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

#include <temporary.h>

Public Member Functions

T & operator * () const
 Access heap object through our temporary directly. More...
 
 operator bool () const
 
 operator T & () const
 
bool operator! () const
 
T * operator() (size_t index) const
 
void operator() (size_t index, const T value)
 
T * operator-> () const
 Access members of our heap object through our temporary. More...
 
temporaryoperator= (const T initial)
 
T & operator[] (size_t index) const
 
size_t read (FILE *fp)
 
void release ()
 
size_t seek (FILE *fp, long pos)
 
 temporary (size_t size=1)
 Construct a temporary object, create our stack frame reference.
 
 temporary (size_t size, const T initial)
 
 temporary (const T initial)
 
T & value (size_t index) const
 
void value (size_t index, const T value)
 
size_t write (FILE *fp)
 

Protected Attributes

T * array
 
size_t used
 

Detailed Description

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

Manage temporary object stored on the heap.

This is used to create a object 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 80 of file temporary.h.

Member Function Documentation

◆ operator *()

template<typename T >
T& ucommon::temporary< T >::operator * ( ) const
inline

Access heap object through our temporary directly.

Returns
reference to heap resident object.

Definition at line 126 of file temporary.h.

◆ operator->()

template<typename T >
T* ucommon::temporary< T >::operator-> ( ) const
inline

Access members of our heap object through our temporary.

Returns
member reference of heap object.

Definition at line 134 of file temporary.h.


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