$include_dir="/home/hyper-archives/boost-users/include"; include("$include_dir/msg-header.inc") ?>
Subject: Re: [Boost-users] polymorphic archive use and memory leak
From: Steven Watanabe (watanabesj_at_[hidden])
Date: 2008-12-02 13:02:53
AMDG
sam p wrote:
>     I am using polymorphic archive in my code and I am using it as 
> follows,
>  
> 1     void func(std::stringstream 
> &ss,  boost::archive::polymorphic_oarchive *&ptr)
> 2    {
> 3         ptr = new boost::archive::polymorphic_text_oarchive(ss);
> 4         return;
> 5    }
> 6    int main()
> 7    {
> 8       std::stringstream ss;
> 9      boost::archive::polymorphic_oarchive *ptr = NULL;
> 10       func(ss, ptr);
> 11       delete ptr;  //Will this delete object properly?????
> 12   }
>  
> Now the question is, whether 'delete' one line no. 11 will work 
> properly or not?
> And is this a right way to use polymorphic archive?
Yes.  polymorphic_oarchive has a virtual destructor.
In Christ,
Steven Watanabe