Cannot alias expression

simendsjo simendsjo at gmail.com
Mon Oct 21 09:51:01 PDT 2013


On Monday, 21 October 2013 at 15:00:26 UTC, Dicebot wrote:
> On Monday, 21 October 2013 at 12:58:55 UTC, John Colvin wrote:
>> I suspect I'm being very dumb here, but I can't get my head 
>> around this:
>>
>>    template B(alias A)
>>    {
>> 	alias B = A;
>>    }
>>    template C(A ...)
>>    {
>> 	alias C = A[0];
>>    }
>>    static assert(B!1 == 1); //fine
>>    static assert(C!1 == 1); //Error: cannot alias an 
>> expression 1
>
> I think this is a good match for a gold collection of "awkward 
> mismatch of template alias vs normal alias". I am quite 
> surprised former template work actually, aliases are not 
> supposed to handle expressions at all. But magic of template 
> alias parameter turns expression into symbol and here we go.

I didn't know the B template would work... Is this correct 
semantics according to the spec?


More information about the Digitalmars-d-learn mailing list