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



_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost

Reply via email to