Question about function type parameter type hints?

Gary Willoughby dev at nomad.so
Mon Jul 15 11:56:37 PDT 2013


class TypeHint
{
	public T method(T)() if (is(T == int))
	{
		return T.init;
	}
}

...

class TypeHint
{
	public T method(T : int)()
	{
		return T.init;
	}
}

...

Are the two above class declarations achieving the same thing? 
i.e. is the type hint of the second snippet shorthand for the 
first's 'if'? If so which is preferred?


More information about the Digitalmars-d-learn mailing list