Boost logo

Boost :

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.

template < typename T >
    void destruct( void * buf )

    typedef void (*destruct_fn_type)( void * buf );

    //like following, but compile time
    template < typename T>
         destruct_fn_type destruct_fn()
                return &destruct<T>;

        //no virtual functions, no runtime polymorphism
        void * ptr = new MyClass;
        destruct_fn_type df = destruct_fn<MyClass>();



Boost list run by bdawes at, gregod at, cpdaniel at, john at