Time for std.reflection
Simen Kjaeraas
simen.kjaras at gmail.com
Mon Jul 23 00:46:33 PDT 2012
On Mon, 23 Jul 2012 08:32:37 +0200, Philippe Sigaud
<philippe.sigaud at gmail.com> wrote:
> Maybe I don't get your comment, but AFAICT, the language does allow
> you to use CTFE parameters values as arguments to templates:
>
> template Twice(double d)
> {
> enum Twice = d * 2;
> }
>
> double foo(double d)
> {
> return d+1.0;
> }
>
> void main()
> {
> enum t = Twice!(foo(1.0));
> pragma(msg, t);
> }
Wrong way around. Try this:
template Twice(double d)
{
enum Twice = d * 2;
}
double foo(double d)
{
return Twice!d;
}
void main()
{
enum t = foo(1.0);
pragma(msg, t);
}
--
Simen
More information about the Digitalmars-d
mailing list