Boost logo

Boost :

Subject: Re: [boost] [outcome] Change semantics on UB from peer review agreed semantics?
From: Andrzej Krzemienski (akrzemi1_at_[hidden])
Date: 2018-09-12 22:25:17

czw., 13 wrz 2018 o 00:18 Peter Dimov via Boost <boost_at_[hidden]>

> Andrzej Krzemienski wrote:
> > You have just described something that one could call "value or throw"
> > idiom: `foo().value()`. It will only work under certain policies: [...]
> The basic point here is that "value or throw" or "value, period" are used
> in
> different ways. One is
> auto r = function().value();
> and the other is
> auto r = function();
> if( r )
> {
> // use the value of `r`
> }
> Since the two forms are distinct, it doesn't really make sense to express
> both using the same name because then you can't tell at a glance whether
> the
> code is correct or not.

Yes, they are two distinct cases. And yes, they should probably be
expressed in two different ways.

> If I remember correctly, one suggestion during the first review was for
> "value, period" semantics to be expressed as `*r`, thereby making both
> options available for the user at the same time. I think that Niall was
> against that as being too short, so he at some point provided "value,
> period" as r.assume_value().
> I'm not sure whether the present `outcome` has assume_value though; the
> reference lists assume_error and assume_exception, but not assume_value.

In the present Outcome you have both `value()` and `assume_value()`. In the
default policy, with default `EC` the former throws and the latter is UB,
but this is in general subject to policy, and if you are nasty, you can
actually configure them the other way around, I think.


> _______________________________________________
> Unsubscribe & other changes:

Boost list run by bdawes at, gregod at, cpdaniel at, john at