On 3/3/15 9:28 AM, Kagamin wrote:
If one wants to prevent a leak, then counter can be wrapped
---
struct Unsafe(T)
{
    private T _payload;
    T payload() @system { return _payload; }
    alias payload this;
}
---
And somehow disallow Unsafe template in safe function signatures, then
having
Unsafe!(int*) _counter;
would be ok?

This is a pretty good idea actually. It's not foolproof (you still have to opt-in to this, the compiler doesn't force it), but it gives you a tool to ensure people aren't using it in an unsafe way without having to double-check every usage. I like it.

-Steve

Reply via email to