alias and mixin

Dicebot via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sun Aug 31 08:32:25 PDT 2014


On Sunday, 31 August 2014 at 14:46:00 UTC, Philippe Sigaud via 
Digitalmars-d-learn wrote:
>> It is basically just an annoying grammar limitation that does 
>> not allow to
>> use mixin / __traits as an identifier.
>
> The usual helper template:
>
> ```
>     alias helper(alias a) = a;
> ```
>
> helps for aliasing __traits and anonymous function templates (x 
> =>
> x+1), but I don't see an easy solution for mixin inside the 
> current
> language, apart from pushing the mixin outside.

I recommend slightly more generic form:

template Alias(T...)
     if (T.length == 1)
{
     alias Alias = T[0];
}

it is quite helpful in templated code to be able to alias 
_anything_

But yeah, no fun for mixins :(


More information about the Digitalmars-d-learn mailing list