Boost logo

Boost :

From: David B. Held (dheld_at_[hidden])
Date: 2004-01-05 13:24:34

"Dan W." <danw_at_[hidden]> wrote in message
> [...]
> Enforcement...
> "If I have a deep_const object I can only access its deep_const
> ...with a bitter rule...
> "deep_const accessors in a class can only access deep_const accessors on
> its members."
> ...and a bit of sweetner...
> " basic_type const * " == " basic_type deep_const * "
> " basic_type const & " == " basic_type deep_const & "
> ...and a bit more sweetener...
> "class x
> {
> (only basic_type members)
> public:
> ... f() const == ... f() deep_const
> };

I guess I'm still not seeing how this works. Let's look at smart_ptr
and review what Thorsten wants. I believe he wants this:

void foo(smart_ptr<T> deep_const& p)
    p->nonConst(); // Boom!

Now, note that I've put the deep_const on the p, and not the T.
That's because he wants the effect that declaring a pointer
deep_const causes the pointee to be const (isn't that the point
of deep const?). Now, obviously, I don't want to declare the
pointee const or deep_const, like so:

    T deep_const* p_;

Because how do you return a non-const pointer without a cast?
And even if you could, would it be the right thing to do? I don't
think so. Now, if deep_const is a conditional property where
T is const only if p_ is const, then I could see how it would be
useful to declare p_ as deep_const. But this is a very bizarre
way of coding, and it isn't obvious that this is what you meant
from your previous posts. But then, I don't see any other way to
use what you're describing to implement a deep_const pointer.
Any light?


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

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