Boost logo

Boost :

From: Peter Dimov (pdimov_at_[hidden])
Date: 2001-04-05 14:31:08


From: "Gary Powell" <Gary.Powell_at_[hidden]>

> > Another point, you are using several C-style casts, why?
>
> MSVC 6.5 complains. Greg had static_cast<> there and the compiler said
> "error C2440: 'static_cast' : cannot convert from const struct derived *'
to
> 'void *'
> Conversion loses qualifiers."
>
> adding a const_cast<element_type *>() doesn't help. if there was a
> remove_const<> it wouldn't work without partial specialization with MSVC.
so
> I went with a "C" cast.

This covers the (void*) casts, the only cast left is in

      template<typename Y>
   auto_ptr(auto_ptr<Y>& rhs) throw()
    : inherited((void *)((element_type *) rhs.release() ) )
   {}

Isn't the (element_type*) cast dangerous?

I don't see a corresponding templated constructor in auto_array_ptr (this is
probably correct) but there is a templated assignment operator? Is this by
design?

> Ok, I now understand the issue with exception safety. So let me just fully
> understand the suggested solution. remove auto_ptr_ref?

Hmm, better leave it as is, if the purpose of boost::auto_ptr is to provide
an implementation of the standard auto_ptr where the compiler doesn't have
one.

--
Peter Dimov
Multi Media Ltd.

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk