On Thursday, 29 August 2013 at 14:34:37 UTC, Joseph Rushton Wakeling wrote:
On 29/08/13 16:13, John Colvin wrote:
struct Limited(T, T lower, T upper)
{
    T _t;
    mixin Proxy!_t; //Limited acts as T (almost)
    invariant()
    {
        enforce(_t >= lower && _t <= upper);
    }
    this(T t)
    {
        _t = t;
    }
}

Is the invariant() not going to be stripped out at compile time if you use -release ?

sadly, yes. We need a release version of them, just like we have enforce and assert. Unfortunately in this case it won't be a library solution and will need compiler support.

Reply via email to