DIP42 - Add enum E(T) = expression; eponymous template support

Xinok xinok at live.com
Sun Jul 21 09:12:04 PDT 2013


On Tuesday, 25 June 2013 at 21:31:15 UTC, Walter Bright wrote:
> http://wiki.dlang.org/DIP42

Reading through this thread, I already foresee a messy 
specification coming along for this. Instead, I'd propose 
something different that would keep the rules consistent yet have 
many more applications:

template(...) declaration = ... ;

So what you would have instead:

template(T) enum E = ... ;
template(T) alias A = ... ;

There's also the possibility for simple template constraints as 
well:

template(T) if(...) enum E = ... ;

Anything more complicated, such as static if, is probably best 
left to the classic style:

template E(T)
{
	static if(...) enum E = ... ;
	else enum E = ... ;
}


More information about the Digitalmars-d mailing list