I can't believe how awful DMD is at removing dead-code. I've tried implementing it like this:

```D
import std.range;

import core.exception;

void assertEx(E : Throwable = AssertError)(lazy bool exp, lazy string msg = null, string file = __FILE__, size_t line = __LINE__)
{
    version(assert)
    if (!exp)
    {
        static if (is(typeof( new E(msg, file, line) )))
            throw new E(msg, file, line);
        else
            throw new E(file, line);
    }
}

void main()
{
    int[] array;
    assertEx!RangeError(!array.empty);
}
```

But even with `-release`, DMD keeps the template around and it calls it.

Even with `-inline`, it keeps the template around.