On Thursday, 23 January 2014 at 16:40:49 UTC, Frustrated wrote:
Yes, I that is what I tried initially but the error was  due to
that static if.

Not sure why

but

                static if (is(T : A))
                {
                      ...
                }
                static assert(0, "error");


doesn't work as the assert is called no matter what. Initially I
forgot to return the value after changing the code but that
doesn't matter.

As it should be. That static assert gets compiled unconditionally, thus asserts.

Had to change it to


                static if (is(T : A))
                {
                      ...
                      return ...;
                } else
                   static assert(0, "error");
                 return null;

I guess because return is not "static" in some sense.

else is the correct thing to do here. Otherwise you could have put a runtime assert(0) there, i.e.:

static if (is(T : A))
{
    return "All is good";
}
assert(0, "This should never happen!");

Reply via email to