Compile-time conversions from string to integer, real, etc.

Walter Bright newshound1 at digitalmars.com
Fri Apr 13 17:17:09 PDT 2007


Don Clugston wrote:
> For example:
> 
> template toString(real x)
> {
>     const char [] toString=x.stringof;
> }
> 
> Unfortunately, none of these work inside a CTFE function. The problem 
> is, that a CTFE function has to also work at runtime, and so it can't 
> use compile-time variables in template value arguments (and it can't 
> index tuples, etc). These kinds of operations are the only ones where 
> template metaprogramming still survives.

I think AST macros should take care of this problem.



More information about the Digitalmars-d mailing list