On Sunday, 16 February 2014 at 02:41:36 UTC, Steven Schveighoffer wrote:
inout does not know when the incoming data is mutable.

Effectively, inout is just like const, but has implications on the return value.

-Steve

Yeah, but say you magically knew the data was mutable.

void logicalConstBump(T)(ref inout(T) t, string originalMutability)
{
    if (originalMutability == "mutable")
    {
        cast(T)t += 1;
    }
    else
    {
        assert(0);
    }
}

Obviously this is extremely contrived, but inout is effectively logical const here. Is there no way to know what the "original" mutability of t is at compile-time?

Reply via email to