www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Templated nested function can't access 'this'

reply Piotr Szturmaj <bncrbme jadamspam.pl> writes:
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
Mar 17 2011
parent Zirneklis <avoi dingspam.cc> writes:
A known bug http://d.puremagic.com/issues/show_bug.cgi?id=3159

Your just gonna have to make it a normal templated method

-- 
Aku MoD.
Mar 17 2011