Boost logo

Boost :

Subject: Re: [boost] [outcome] To variant, or not to variant?
From: Peter Dimov (lists_at_[hidden])
Date: 2017-06-03 10:11:34


Andrzej Krzemienski wrote:

> Peter, I do not understand what you are trying to say here. You say you
> have observed some useful behavior when your trick with operator-> is
> applied.

Trick?

> I am asking what it is. It is still an UB when used, so there must be
> something to it. My guess would be that UB on null pointer is more
> tool-friendly than UB on just any bad pointer. But if it should be the
> case, why did you say you would like the same trick in shared_ptr? It
> deals with dereferencing a nullptr both with and wothout your hack.

As I say in my reply to Vicente, specifying operator-> in this way leads to
consistent behavior for the expression `p->x` when p is a raw pointer, a
smart pointer, or, in this case, result<>/outcome<>. The same optimization
decisions apply, the same command-line compiler switches apply, in a
consistent manner.


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk