Confusion/trying to understand CTFE keywords

David Bennett davidbennett at bravevision.com
Fri Jun 8 03:51:11 UTC 2018


On Thursday, 7 June 2018 at 04:58:40 UTC, Jonathan M Davis wrote:
>
> It would be trivial enough to create a wrapper template so that 
> you can do something like
>
> immutable n = ctfe!(foo());
>
> e.g.
>
> template ctfe(alias value)
> {
>     enum ctfe = value;
> }
>

Would this be equivalent to using static immutable?

static immutable n = foo();

In this case both the compiletime and runtime values were 
calculated using cfte.

Also back to the OP the way I think of enum, static types is like 
this:

alias and enum create compiletime stuff from compiletime stuff.
static creates runtime stuff from compiletime stuff.

Is that view valid in most cases?




More information about the Digitalmars-d-learn mailing list