Using "cast(enum)" for explicit request of ctfe

monarch_dodra monarchdodra at gmail.com
Wed Dec 4 05:16:34 PST 2013


On Wednesday, 4 December 2013 at 11:51:11 UTC, Jakob Ovrum wrote:
> Right, maybe it should be (substitute the name `eval`):
>
> ---
> template eval(alias exp) if(isExpressionTuple!exp)
> {
>     static immutable eval = exp;
> }
> ---
>
> Which might make it avoid the pitfalls of using enum. Not sure 
> if the `static` actually does something in this context, IIRC 
> it does not.

Problem is that doing this returns an immutable type, which isn't 
quite the same as a ctfe variable (which was the initial goal, as 
far as I'm concerned)

> No idea where to put it. I've experimented with such a template 
> before but I haven't used it in any real code. object.d and 
> std.typecons come to mind, but I don't particularly like the 
> prospect of putting it in either.

Yeah... I wouldn't want to import all of typecons just for this, 
but if we split it into packages, it would perfectly fit in its 
own little package (IMO).


More information about the Digitalmars-d mailing list