On alias a = b

KennyTM~ kennytm at gmail.com
Fri Mar 18 13:53:14 PDT 2011


On Mar 19, 11 04:41, Steven Schveighoffer wrote:
> On Fri, 18 Mar 2011 16:37:49 -0400, Andrei Alexandrescu
> <SeeWebsiteForEmail at erdani.org> wrote:
>
>> On 3/18/11 3:28 PM, so wrote:
>>> alias a(T) = b(T, known_type);
>>>
>>> Would it be an overkill?
>>
>> It's part of the evil plan.
>
> (I think there is a typo above, shouldn't it be alias a(T) = b!(T,
> known_type) ? )
>
> You mean you would no longer need the surrounding template declaration?
>
> i.e. the above (corrected) statement would be short for:
>
> template a(T)
> {
> alias a = b!(T, known_type);
> }
>
> That would be certainly very un-evil ;)
>
> -Steve

Being evil would be:

alias staticReduce(alias F, alias Init) = Init;
alias staticReduce(alias F, alias Init, T...) if (T.length != 0) = 
staticReduce!(F, F!(Init, T[0]), T[1..$]);
//                                            ^ support conditionals?
enum addSize(int total, T) = total + T.sizeof;
// ^ yeah why not generalize to enum too?

static assert(staticReduce!(addSize, 0, byte, short, int, long[2], 
float, double) == 35);


;)


More information about the Digitalmars-d mailing list