does cast make an lvalue appear to be an rvalue

Daniel Davidson nospam at spam.com
Wed Oct 16 11:11:46 PDT 2013


On Wednesday, 16 October 2013 at 17:55:56 UTC, Dicebot wrote:
> struct S {
>   R r;
>   this(ref immutable(T) t) immutable {
>     r.tupleof = t.tupleof;
>   }
> }
>
> ?

Thanks. It is cute - but not so helpful. The example stands. I 
*need* to call a createRFromT.

Their shapes are the same in this simple example because I 
simplified. Make R look like:

struct R {
   string[string] ss;
   int[] j;
}

and the cute trick falls apart. In words, I have an R and I want 
to make a T. The R is const the T will be immutable because the 
ctor requires it. But it is technically not immutable until it is 
initialized.


More information about the Digitalmars-d-learn mailing list