Cannot alias expression
Timon Gehr
timon.gehr at gmx.ch
Tue Oct 22 04:16:08 PDT 2013
On 10/21/2013 02:58 PM, 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
It is awkward design. I think it should just work. In case you needed to
this for anything, the following works:
template ID(alias a){ alias ID = a; } // "identity function on symbols"
template B(alias A){
alias B = A;
}
template C(A ...){
alias C = ID!(A[0]);
}
static assert(B!1 == 1); // fine
static assert(C!1 == 1); // fine
More information about the Digitalmars-d-learn
mailing list