Re: weak_ptr alternative

2018-08-05 Thread Kamil Koczurek via Digitalmars-d-learn
On Sunday, 5 August 2018 at 20:57:32 UTC, aliak wrote: On Sunday, 5 August 2018 at 20:10:49 UTC, Kamil Koczurek wrote: Is there a way to keep track of objects without owning them? That is, could I have a smart pointer that behaves somewhat like this: WeakPtr!Class wptr = getSomeInstance(); au

Re: weak_ptr alternative

2018-08-05 Thread aliak via Digitalmars-d-learn
On Sunday, 5 August 2018 at 20:10:49 UTC, Kamil Koczurek wrote: Is there a way to keep track of objects without owning them? That is, could I have a smart pointer that behaves somewhat like this: WeakPtr!Class wptr = getSomeInstance(); auto obj = wptr.peek; //[1] if(obj !is null) { obj.stuff

weak_ptr alternative

2018-08-05 Thread Kamil Koczurek via Digitalmars-d-learn
Is there a way to keep track of objects without owning them? That is, could I have a smart pointer that behaves somewhat like this: WeakPtr!Class wptr = getSomeInstance(); auto obj = wptr.peek; //[1] if(obj !is null) { obj.stuff(); } [1]: If wptr points to something that is still reachable fr