alias restriction??!
Carl Sturtivant
sturtivant at gmail.com
Sun Jul 19 12:42:47 UTC 2020
On Sunday, 19 July 2020 at 12:08:07 UTC, Paul Backus wrote:
> On Saturday, 18 July 2020 at 18:46:16 UTC, Carl Sturtivant
> wrote:
>> Here's a toy version of a problem in the wild.
>>
>> struct S {
>> long first;
>> union T {
>> long one;
>> double two;
>> }
>> T second;
>> alias First = first;
>> alias Second = second.one;
>> }
>>
>> void main() {
>> S x;
>> x.First = 4;
>> x.Second = 5; // compilation error: "Error: need this for
>> one of type long"
>> }
>
> Easiest workaround:
>
> ref inout(long) Second() inout { return second.one; }
Was trying to avoid this for performance reasons. In fact what
are the performance implications of this sort of thing with
current implementations? --- relative to using a simple offset.
More information about the Digitalmars-d-learn
mailing list