Boost logo

Boost :

From: Dan W. (danw_at_[hidden])
Date: 2004-01-05 02:41:35

David B. Held wrote:
> 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.

I must confess I haven't thought that deep-ly about it :)

Let me see if whatever I did fancy could work:

class y;

class x
    y deep_const *a;
    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

Probably it's not that simple, but I don't see why it isn't at the moment...

Boost list run by bdawes at, gregod at, cpdaniel at, john at