D needs first-class lifetimes before it can get ownership and borrowing
a11e99z
black80 at bk.ru
Sat Aug 10 18:11:18 UTC 2019
On Saturday, 10 August 2019 at 17:38:43 UTC, Nick Treleaven wrote:
> On Saturday, 10 August 2019 at 13:30:17 UTC, Olivier FAURE
>
> struct SmartPtr {
> scope int* ptr
>
should there be an opportunity to transfer ownership?
SmartPtr {
int* transfer() [@forget, @transfer, @orsomethingelse] { return
ptr; /*ptr = null;*/ }
}
and then need attr @nodiscard with error when returned value is
discarded cuz memory/handle leak can be.
More information about the Digitalmars-d
mailing list