@trusted and return ref

Kagamin via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Tue Mar 3 06:28:10 PST 2015


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?


More information about the Digitalmars-d-learn mailing list