A struct with a tuple as alias this, is kind of confusing

Yuxuan Shui yshuiv7 at gmail.com
Fri Jul 27 10:52:06 UTC 2018


On Friday, 27 July 2018 at 10:48:08 UTC, ag0aep6g wrote:
> On 07/27/2018 12:19 PM, Yuxuan Shui wrote:
>> On Friday, 27 July 2018 at 10:17:21 UTC, Yuxuan Shui wrote:
>>> [...]
>> 
>> Oh no, is it just defining arrays in the is() statement, 
>> though?
>
> Yup.
>
>> But wait, this works:
>> 
>> alias C = A!(1,2,3);
>> static if (C[0] < C[1])
>>     pragma(msg, "Ha!");
>
> Looks like DMD decides that `C[0]` and `C[1]` can't be types in 
> that situation, so it tries the alias this. That's in line with 
> how alias this is supposed to work: only kick in when the code 
> wouldn't compile otherwise.

Let's just say this is confusing as hell.


More information about the Digitalmars-d mailing list