D needs first-class lifetimes before it can get ownership and borrowing

Mike Franklin slavo5150 at yahoo.com
Sat Aug 10 23:59:14 UTC 2019


> I think it's because you didn't declare it as `scope SmartPtr 
> s;` and `reset` is wrongly @trusted.

`SmartPtr` is a struct so it's implicitly `scope`.  Also, I think 
the `@trusted` annotation is only to allow the usage of `malloc` 
and `free` which aren't safe.  I think for this illustration, the 
`@trusted` annotation is OK.

Mike


More information about the Digitalmars-d mailing list