|
Boost Users : |
Subject: Re: [Boost-users] boost::exception_detail::error_info_base does not have virtual destructor
From: Emil Dotchevski (emildotchevski_at_[hidden])
Date: 2011-03-18 14:50:57
On Fri, Mar 18, 2011 at 8:55 AM, Ted Byers <r.ted.byers_at_[hidden]> wrote:
> The type for the container would be:
> std::vector<boost::shared_ptr<base_type> >
>
> boost::shared_ptr<base_type> and boost::shared_ptr<derived_type> are two
> different types. You can't cast from the one to the other without writing
> code to do it. So, to make one vector containing (smart) pointers to
> instances of any or all the derived types, you would have to cast the
> pointers to instances the derived types to the base before you create the
> shared_ptr.
Put the return value from new directly into a shared_ptr -- it'll just work!
When the object expires, shared_ptr will not call the destructor
through a base pointer, so the base destructor should be protected
(and non-virtual) to protect from someone attempting to call delete on
a base pointer.
Emil Dotchevski
Reverge Studios, Inc.
http://www.revergestudios.com/reblog/index.php?n=ReCode
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net