CTFE determination?

Sergey Gromov snake.scaly at gmail.com
Fri Sep 12 13:01:46 PDT 2008


bmeck <bmeck at stedwards.edu> wrote:
> well any suggestion on how to determine if a parameter is constant at 
> run time? that is my goal overall... right now it seems casting to 
> invariant ruins anything I can come up with.

I cannot quite understand what are you trying to achieve here.  This is 
my solution if I got you right:

---
import std.stdio;

void main(string[] args)
{
	
	writefln("test");

	static if (__traits(compiles, CompileTime!("123")))
		writeln("123 compile");
	else
		writeln("123 run");

	static if (__traits(compiles, CompileTime!(args[0])))
		writeln("args[0] compile");
	else
		writeln("args[0] run");

}

template CompileTime(alias Expr)
{
}
---



More information about the Digitalmars-d mailing list