On 2013-08-29 13:19, Joseph Rushton Wakeling wrote:

So, I thought I'd throw the idea out there so that others can suggest
whether this is potentially useful or whether it's better/safer to
hand-code such checks on a function-by-function basis.

You can quite easily create a wrapper for that.

struct EnforceWrapper (T)
{
    T t;

    auto opDispatch (string name, Args ...) (Args args)
    {
        // before code
        mixin("auto result = " ~ name ~ "(args);");
        // after code
        return result;
    }
}

auto obj = EnforceWrapper!(Object)(new Object);
obj.toString();

--
/Jacob Carlborg

Reply via email to