$include_dir="/home/hyper-archives/boost/include"; include("$include_dir/msg-header.inc") ?>
From: Bohdan (gejrlaug_at_[hidden])
Date: 2003-06-06 11:57:40
IMHO a very useful addon to your library can be routine
to convert class to function which calls class destructor.
<code>
template < typename T >
void destruct( void * buf )
{
reinterpret_cast<T*>(buf)->~T();
}
typedef void (*destruct_fn_type)( void * buf );
//like following, but compile time
template < typename T>
destruct_fn_type destruct_fn()
{
return &destruct<T>;
}
//ex:
//no virtual functions, no runtime polymorphism
void * ptr = new MyClass;
destruct_fn_type df = destruct_fn<MyClass>();
....
df(ptr);
</code>
regards,
bohdan