Modify const reference data
Heinz
thor587 at yahoo.com
Mon Dec 9 09:38:47 PST 2013
> Apparently the OP intended to set it in foo(). If the data is
> actually mutable and there really is no way other than going
> against the type system, foo() must be called at least once and
> can be implemented like this:
>
> public void foo()
> {
> abc = [1,2,3,4];
> cast(ubyte*)data = abc.ptr;
> }
>
> // ...
>
> B b = new B();
> b.foo();
> b.print(); // now OK
>
> Ali
Wow, i didn't know i could cast out constness from an lvalue.
This is what i needed. I'll try it in my code as soon as i can.
Thanks.
More information about the Digitalmars-d-learn
mailing list