can I generate an enum from a typelist?

monarch_dodra monarchdodra at gmail.com
Wed Apr 9 01:50:11 PDT 2014


On Wednesday, 9 April 2014 at 07:37:18 UTC, Vlad Levenfeld wrote:
> On Wednesday, 9 April 2014 at 00:27:48 UTC, bearophile wrote:
>> Vlad Levenfeld:
>>
>>> alias Layer = Algebraic !(Solid, Gradient, Text, Sprite, 
>>> Plane);
>>
>> I suggest no space before the bang when you instantiate 
>> templates.
>>
>> Bye,
>> bearophile
>
> Because it will be more easily confused with a logical not 
> operator?

Because it's generic D syntax. what's on the right of "!" are 
considered the parameters of what's on the left. The "whole" is 
considered a "word" of sorts. If you apply a space, it inserts a 
break in the word, which looks weird.

And yes, it does add a bit of confusion (but that's mostly 
because I've *never* actually seen a space before the parameter 
specifier "!").

Also, if you've already defined the type tuple "Types", then you 
can just use that:

alias Layer = Algebraic!Types;

Short and sweet.


More information about the Digitalmars-d-learn mailing list