Boost logo

Boost :

Subject: Re: [boost] [review] **NEXT WEEK** Review of Outcome (starts Fri-19-May)
From: Peter Dimov (lists_at_[hidden])
Date: 2017-05-15 10:37:19


Andrzej Krzemienski вроте:
> vector<outcome<T>> os (20); // no value or error to assign yet
>
> for (auto const& e : some_collection)
> if (cond(e))
> os[i].set_value();
> else
> os[i].set_exception();

.set_error presumably. (Incidentally, result<> is documented to have
set_exception, which makes no sense to me.)

> And in some cases, you cannot immediately rewrite the code in order to
> avoid default construction. You do not want to return an "empty" object,
> but you need this value temporarily, end there may be no good value of `E`
> to use.

The argument that it's better to default-construct to some kind of a
valueless state instead of T{} is legitimate, but even if I grant all the
premises of that example (which is a stretch), I still don't see why
default-constructing to make_error_code( outcome_errc::uninitiaized ) isn't
better than special-casing the empty state.


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