Deferrer Struct Template Reference
[Miscellaneous constructs used by Vaucanson]

This class defers the creation of its template parameter. More...

Inheritance diagram for Deferrer:

Inheritance graph
[legend]

List of all members.

Public Member Functions

 Deferrer ()
 Constructor.
Deferreroperator= (const deferred_type &)
 Effectively builds the holded type.
 operator T () const
 Get back the holded type.

Protected Attributes

data_t data
 A flat area of memory big enough to hold an instance of deferred_type.


Detailed Description

template<class T, bool rt_checks = deferrer_runtime_checks_default>
struct vcsn::misc::Deferrer< T, rt_checks >

This class defers the creation of its template parameter.

This class is designed to hold a instance of type T, without initializing it when the class is created. In fact, the construction of T is deferred to a later time, using operator=. This may be usefull when you want to equip a class with a constructor without arguments.

Using a Deferrer may be dangerous, e.g. when you make a call to the cast operator without having initialized the referred type with a call to operator=.

Because of that danger, you can optionally enable or disable some runtime checks by respectively set or clear a second Boolean template parameter.

When you compile without the NDEBUG macro, this parameter defaults to true (checks enabled). Else it defaults to false (checks disabled).

Author:
Thomas Claveirole

Definition at line 96 of file deferrer.hh.


Member Data Documentation

data_t data [protected]

A flat area of memory big enough to hold an instance of deferred_type.

Using this kind of trick forces us to do a lot of ugly casts (after all, data_t is just an array of char), but as a result there are no dynamic allocations.

Definition at line 132 of file deferrer.hh.

Referenced by Deferrer::operator T(), and Deferrer::operator=().


Generated on Thu Sep 17 22:02:01 2009 for Vaucanson by  doxygen 1.5.6