On Thursday, 1 September 2016 at 21:07:36 UTC, Steven Schveighoffer wrote:
On 9/1/16 4:38 PM, Yuxuan Shui wrote:
[...]

Referring to a null object is not a problem. Your program crashes ungracefully, but does not corrupt memory. However, in either approach, it can easily end up being a dangling pointer.

But to refer to a null location is quite easy:

int *foo; // null ptr
auto a = x(*foo);
assert(&a.xa() == null);

Your approach is less desirable because of the closure to point at a given reference which can be had with just a reference. Needless allocation.

-Steve

Makes sense. Thanks!

Reply via email to