|
Boost : |
From: Ralf W. Grosse-Kunstleve (rwgk_at_[hidden])
Date: 2006-03-09 18:12:12
--- Sebastian Redl <sebastian.redl_at_[hidden]> wrote:
> >I know it works on a large number of platforms (several versions of EDG, VC,
> >g++). valgrind also didn't have any complaints. Is the approach also OK from
> a
> >theoretical viewpoint?
> >
> I don't know about STLport's approach, but const-casting the parameter
> is definitely not OK from a theoretical viewpoint.
OK, but my question was more: is my approach backed up by the ISO standard, or
does it work just by chance?
> Your const parameter
> is a promise that you won't modify the parameter, but then you go ahead
> and do it anyway.
> You should make the parameter non-const, like the GNU C++ library does
> with auto_ptr:
> auto_ptr(auto_ptr& __a) throw() : _M_ptr(__a.release()) { }
The problem is that my code doesn't compile (g++ 3.4.2) if I remove the
"const". I've tried adding the throw() but that didn't do it. I see there is
also an auto_ptr_ref<> in the g++ library, but I don't know if this is what
does the trick. Could one of the C++ gurus please explain?
BTW: Assuming that I can get my auto_array to work without the const, in the
copy constructor and assignment operator, what is the difference between
const auto_array<T>
and
scoped_array<T>
?
Apart from the release() it looks almost the same.
Ralf
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk