does cast make an lvalue appear to be an rvalue
Daniel Davidson
nospam at spam.com
Wed Oct 16 13:17:48 PDT 2013
On Wednesday, 16 October 2013 at 19:49:25 UTC, monarch_dodra
wrote:
> On Wednesday, 16 October 2013 at 17:50:48 UTC, Daniel Davidson
> wrote:
>> How do you propose to make a mutable copy *generically*?
>
> You can't. Let alone generically.
>
> If I give you an "immutable int* p", how do you copy it to
> "int* p" ?
>
That was my point.
> On Wednesday, 16 October 2013 at 18:11:48 UTC, Daniel Davidson
> wrote:
>> 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.
>
> The problem is that you are taking a const(R). And you can't
> assign a const to an immutable. It has nothing to do with
> initialization.
>
No I don't think I am. What code are you looking at?
>
> A copy *might* not be necessary provided building an immutable
> copy from mutable is actually legal. This is not your case.
>
> What you are doing is warping the type system.
Based on your previous comment, I don't think you understood the
setup.
More information about the Digitalmars-d-learn
mailing list