Boost logo

Boost :

Subject: Re: [boost] [outcome] Change semantics on UB from peer review agreed semantics?
From: Peter Dimov (lists_at_[hidden])
Date: 2018-09-12 22:18:16


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.

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.


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