Can not override template and nontemplate function

ilya-stromberg ilya-stromberg-2009 at yandex.ru
Sat Aug 31 03:28:07 PDT 2013


D can not override template and nontemplate function:

void foo(bool param)
{
	if(param)
	{
		//do something useful
	}
	else
	{
		//do something else
	}
}

void foo(bool param)()
{
	static if(param)
	{
		//do something useful
	}
	else
	{
		//do something else
	}
}

void main()
{
}

dmd output:
src/main.d(13): Error: template main.foo(bool param)() conflicts 
with function main.foo at src/main.d(1)

Does exist any reason to deny this, or it's just compiler bug?
I think that compiler can always understand what I want:

//nontemplate function call
foo(true);
//template function call
foo!true();


More information about the Digitalmars-d mailing list