Boost logo

Boost :

From: Gary Powell (Gary.Powell_at_[hidden])
Date: 2001-04-05 13:40:40


>>
> 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.

>>
> > new int(1)
> > new int(2) // throws
> > auto_ptr<int>(new int(1))
> > auto_ptr<int>(new int(2))
> >
> > is a valid sequence. See http://www.gotw.ca/gotw/056.htm .
>
<<
Ok, I now understand the issue with exception safety. So let me just fully
understand the suggested solution. remove auto_ptr_ref?

This worked for gcc, but not MSVC 6.5 (silent compile)
and it made

auto_ptr<T> source() {
 return auto_ptr<T>(new T);
}
not compile. Which I thought I needed for things like "clone(type const &)"

Would you rather have a auto_ptr_new solution? (With up to say 10 predefined
arguments?)

  -gary-

gary.powell_at_[hidden]


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