some template questions

BCS BCS_member at pathlink.com
Sat May 20 17:29:57 PDT 2006


Two questions:

This is supposed to make a list of all numbers from 0 to i, can it be made to
work, and if so how?

template list(int i)
{
static if(i==0)
int[] list = [0];
else
int[] list = list!(i-1) ~ i;	
}

Should this hang or should the static assert kill it before it loops? (as of
0.157, it hangs)

template hang()
{
static assert(false);
const int hang = hang!();
}





More information about the Digitalmars-d-learn mailing list