Boost logo

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-17 16:06:58


On Thu, Mar 17, 2011 at 12:53 PM, Jens Auer <jensa_at_[hidden]> wrote:
>>> Well, that's true for exception_detail, but error_info has a public non-virtual destructor and might be used as a base class (I am sure it isn't, but when I just have a quick look at it when coding it doesn't say that it shouldn't).
>>>
>>> error_info has a protected (not public) non-virtual destructor, by design.
>
> Just checked the code provided in 1.46.1:
>   template <class Tag,class T>
>    class
>    error_info:
>        public exception_detail::error_info_base
>        {
>        public:
>
>        typedef T value_type;
>
>        error_info( value_type const & value );
>        ~error_info() throw();
>
>        value_type const &
>        value() const
>            {
>            return value_;
>            }
>
>        value_type &
>        value()
>            {
>            return value_;
>            }
>
>        private:
>
>        std::string tag_typeid_name() const;
>        std::string value_as_string() const;
>
>        value_type value_;
>        };
>    }

I mistyped, yes error_info has a public destructor, but it isn't a
base type; error_info_base is the base type which has protected
non-virtual destructor. I am not concerned about the potential danger
of someone newing an object of a type that derives from
boost::error_info. :)

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