static if or version for CTFE

bmeck bmeck at stedwards.edu
Wed Aug 27 22:46:06 PDT 2008


Sorry for double post but this works if a lil hackey and a dislikable branch occurs at runtime slowing it a bit...

void main(char[][] args)
{
	Stdout(test("true")).newline;
	Stdout(test(args[0])).newline;
	
}

bool CTFE = true;
static this()
{
	CTFE = false;
}
char[] test(char[] src)
{
	if(CTFE)
	{
		return src;
	}
	else
	{
		return src;
	}
}



More information about the Digitalmars-d mailing list