Boost logo

Boost :

From: David B. Held (dheld_at_[hidden])
Date: 2004-01-03 03:18:22


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

Dave

---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.556 / Virus Database: 348 - Release Date: 12/26/2003

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