Boost logo

Boost :

From: Thorsten Ottosen (nesotto_at_[hidden])
Date: 2004-01-03 03:31:36


"David B. Held" <dheld_at_[hidden]> wrote in message
news:bt5trp$s2m$1_at_sea.gmane.org...
> "Thorsten Ottosen" <nesotto_at_[hidden]> wrote in message
> news:bt5ip0$ge1$1_at_sea.gmane.org...
> > [...]
> > Having propagation of constness makes a lot of sense and
> > would certainly make the smart pointers a lot smarter.
>
> At first, I thought so too. But then I thought about what raw pointers
> do, and I decided that it was better to mimic the built-ins. If you
> always propagate constness, then you can't have a const ptr to a
> non-const object. Maybe that doesn't bother you, but perhaps there
> is a scenario in which you want to be able to modify the pointee in
> a function, but you don't want to accidentally reset() or release() the
> pointer in that function. Propagation of constness eliminates this
> possibility.

Why? Can't you cast the constness away?

I really don't understand why correctness should
not be the default and then let those who want it do the hacks?

> The solution for deep-const is smart_ptr<T const>. It's
> not perfect, but I think it's the right thing to do.
>
> > [...]
> > smart_ptr< const T, deep_copy > ?
>
> Yes, exactly. That puts constness where it belongs.

Maybe, my though was that your pointer was partially specialized for const T
to
be const-correct; you might have thought of it as the normal style :-).

br

Thorsten


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