Mutable reference to const objects

Yuxuan Shui via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Wed Jul 1 01:33:41 PDT 2015


On Wednesday, 1 July 2015 at 08:30:23 UTC, Yuxuan Shui wrote:
> How do I express a mutable reference to a const object in D?
>
> What I want to do is to define a variable, which refers a 
> constant object, but I can change which constant object it is 
> referring. Is this possible?

I wonder will something like:

class Const(T):
     const(T) inner;
     alias this inner;
}

work?


More information about the Digitalmars-d-learn mailing list