This is clearly an incorrect way because it requires editing the
original definition every time a new class is introduced.
On Saturday, 29 November 2014 at 19:10:34 UTC, Meta wrote:
On Saturday, 29 November 2014 at 18:19:40 UTC, Sly wrote:
You miss another definition which introduces a conflict:
T getResponse(T)(string question)
{...}
In that case, you're better off with a pair of declarations:
struct Point(T)
{
T x;
T y;
}
T getResponse(T)(string message)
if (!is(T == Point!U, U))
{
return T.init;
}
Point!T getResponse(T)(string message)
if (is(T == Point!U, U))
{
return Point!T(T.init, T.init);
}
void main()
{
auto t = getResponse!int("test");
auto p = getResponse!(Point!int)("test");
}