Storing a reference
Rene Zwanenburg via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Thu Sep 1 14:03:27 PDT 2016
On Thursday, 1 September 2016 at 20:38:13 UTC, Yuxuan Shui wrote:
> I think my approach is probably better, because I believe
> (correct me if I'm wrong): 1) it will never refer to a null
> object.
That's true, but you can ensure the same thing for the wrapper:
struct Ref()
{
@disable this();
this(T* value)
{
assert(value !is null);
this.value = value;
}
// rest same as before
}
> 2) after DIP1000 is implemented we will be able to make sure
> there will be no dangling reference.
I'm not very familiar with the details of DIP1000, so I can't
comment on that.
More information about the Digitalmars-d-learn
mailing list