Go to the documentation of this file.00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
00016 
00017 #ifndef VCSN_MISC_DEFERRER_HH
00018 # define VCSN_MISC_DEFERRER_HH
00019  
00031 namespace vcsn
00032 {
00033   namespace misc
00034   {
00035 
00038 # ifndef VCSN_NDEBUG
00039     enum { deferrer_runtime_checks_default = true };
00040 # else // VCSN_NDEBUG
00041     enum { deferrer_runtime_checks_default = false };
00042 # endif // ! VCSN_NDEBUG
00043 
00045 
00046     template <class T, bool B>
00047     struct DeferrerDebugPart
00048     {
00049       protected:
00050         
00051         DeferrerDebugPart (void* ptr, bool is_valid = false);
00052 
00053         void     set_valid (bool b);
00054         T&       cast (void*);
00055         const T& cast (const void*) const;
00056 
00057         bool is_valid_;
00058     };
00059 
00060     template <class T>
00061     struct DeferrerDebugPart<T, false>
00062     {
00063       protected:
00064         
00065         DeferrerDebugPart (void* ptr, bool is_valid = false);
00066         void     set_valid (bool b);
00067         T&       cast (void*);
00068         const T& cast (const void*) const;
00069     };
00095     template <class T, bool rt_checks = deferrer_runtime_checks_default>
00096     struct Deferrer : DeferrerDebugPart<T, rt_checks>
00097     {
00098         typedef T deferred_type;
00099 
00108         Deferrer ();
00109 
00117         Deferrer&
00118         operator= (const deferred_type&);
00119 
00121         operator T () const;
00122       protected:
00123         typedef unsigned char data_t[sizeof (deferred_type)];
00124 
00132         data_t data;
00133     };
00134 
00136   } 
00137 } 
00138 
00139 # if !defined VCSN_USE_INTERFACE_ONLY || defined VCSN_USE_LIB
00140 #  include <vaucanson/misc/deferrer.hxx>
00141 # endif // VCSN_USE_INTERFACE_ONLY
00142 
00143 #endif // ! VCSN_MISC_DEFERRER_HH