compile-time explicitness
Jonathan M Davis
jmdavisProg at gmx.com
Fri Sep 23 11:45:51 PDT 2011
On Friday, September 23, 2011 11:15 Gor F. Gyolchanyan wrote:
> It's not a performance issue.
> You can't do this:
>
> if(_ctfe)
> to!string(...);
> else
> toStringNow!(...);
>
> because the toStringNow!(...) won't compile, because it's argument is not a
> compile-time value.
So, use a normal function. The main reason to use _ctfe is because the normal
function doesn't work with CTFE for one reason or another, and so you use a
less efficient function which _can_ do it at compile time. Since you're
operating on a value rather than a type, there's no reason why you can't use a
function rather than an eponymous template.
- Jonathan M Davis
More information about the Digitalmars-d
mailing list