Why can't we define re-assignable const reference variable?
Janice Caron
caron800 at googlemail.com
Sun Feb 17 23:16:18 PST 2008
On 17/02/2008, Sönke Ludwig <ludwig at informatik_dot_uni-luebeck.de> wrote:
> Show me how I can maintain a simple map of class instances, which I get as
> const(C) from somewhere else, i.e. I have to accept the const here.
>
> example:
>
> const(C)[string] map;
>
> <- completely useless - you can do nothing with this construct
So change it to
const(C)*[string] map;
Now you've a map of mutable pointers, indexed by string. It's not hard.
> or to use a struct S { const(C) obj }
That probably won't work in the future. You're basically exploiting a
bug there, and I imagine that soon it will be fixed.
More information about the Digitalmars-d
mailing list