|
Boost : |
From: David B. Held (dheld_at_[hidden])
Date: 2004-01-05 04:10:36
"Dan W." <danw_at_[hidden]> wrote in message
news:btb4ff$gmk$1_at_sea.gmane.org...
> [...]
> class x
> {
> y deep_const *a;
> public:
> y* get_a(); //boom!
> y const * get_a() const; //boom!
> y deep_const * get_a() deep_const; //ok
> y const * get_get_a() const
> {
> get_a(); //boom!
> }
> y deep_const * get_get_a() deep_const
> {
> get_a(); //ok
> }
> };
> [...]
Ok, so how would this apply to our smart_ptr<> example? Maybe:
smart_ptr<T> deep_const p;
>From what I can tell, this would require us to define deep_const
accessors inside smart_ptr<> and/or do a deep_const_cast<>
of the raw pointer. But then, that doesn't seem to be any
different from implementing deep const manually. Are you
suggesting that the language *enforce* deep const, but not
actually *help* you implement it? At least const propagates
to aggregated members, so it is both enforcing a property and
helping you out at the language level. But from what I can see
above, you're just asking for enforcement, with a parallel
const concept. What I was thinking is that if you declare an
object deep_const, it will make all pointers inside that object
const/deep_const as well, without you ever having to declare
deep const versions of anything; just like declaring an object
const makes the members effectively const. So it's not y or
y* that we want to make deep_const. It's an instance of x.
What we really should be asking ourselves is how
x deep_const X;
is implemented/behaves.
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