typeof([2,2]) !=? int[2]

Zhenya zheny at list.ru
Fri Mar 8 14:45:08 PST 2013


Hi!
Explain me please,what's wrong with this code:

struct NDimensionalArray(T,alias size)
	if(is(typeof(size) _ == int[n],int n) &&
	   n > 0)
{
	static if(n > 1)
		NDimensionalArray!(T,n - 1,size[1..$]) m_array[size[0]];
	else
		T m_array[size[0]];
	alias m_array this;
}

void main()
{
	NDimensionalArray!(int,[2,2]) array;
	array[0][1] = 1;
}

It fails with message:
Error: template instance NDimensionalArray!(int, [2, 2]) 
NDimensionalArray!(int, [2, 2]) does not match template 
declaration NDimensionalArray(T, alias size) if (is(typeof(size) 
_ == int[n],int n) && n > 0)
on dmd git-head.


More information about the Digitalmars-d-learn mailing list