Templated nested function can't access 'this'

Piotr Szturmaj bncrbme at jadamspam.pl
Thu Mar 17 15:51:48 PDT 2011


Why this works:

struct Test
{
	int read()
	{
		return 5;
	}
	
	int[] readArray()
	{
		int[] readDim()
		{
			return [read(), read()];
		}
		
		return readDim();
	}
}

but after changing nested function to function template, it doesn't:

struct Test
{
	int read()
	{
		return 5;
	}
	
	int[] readArray()
	{
		int[] readDim(T)()
		{
			return [read(), read()];
		}
		
		return readDim!int();
	}
}

Error: need 'this' to access member read

TIA


More information about the Digitalmars-d-learn mailing list