Boost logo

Boost :

From: David B. Held (dheld_at_[hidden])
Date: 2004-01-05 01:46:19


"Dan W." <danw_at_[hidden]> wrote in message
news:btb04e$b5e$1_at_sea.gmane.org...
> [...]
> What I argued for, then, was introducing deep variants of language
> keywords, and I apologize for bringing up a 'language' issue here,
> but I would not mind to see C++ introducing...
>
> deep const
> [...]

How exactly would you implement deep const at the language
level? I can see deep =, because I presume that works with
aggregated classes. But the deep const that Thorsten wants
is fundamentally different, since it doesn't just propagate to
members, which is what const already does. It propagates
*through* members, changing their types in a radical way. What
it really does is cross wrapper boundaries, and that sounds like
an insane thing to try to make a compiler do. I mean, we're talking
about something like this:

struct ptr deep_const
{
    T* p_;
};

ptr const x;

=>

T const* const p_;

Right? So is that all it is? Just traverse down all pointer and
array types, adding const at every level? How about this:

struct raw_ptr
{
    T* p_;
};

struct ptr_wrapper deep_const
{
    raw_ptr p_;
};

Now, does deep_const go inside every class definition, and
make those members const too? Does it make raw_ptr a
deep_const type when it is aggregated within ptr_wrapper?
I mean, I see that it could probably be done, but I don't think
I'd want to write it. ;) And if a class were designed for shallow
const, but got deep_const-ed via aggregation, that could have
some suprising effects, no? And if deep_const doesn't go
that deep, then wrapper types like the above severely limit
its usefulness, no? I'm not saying it's a bad idea, necessarily.
I'm just wondering if it solves more problems than it creates.

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