Boost logo

Boost :

Subject: Re: [boost] [outcome] outcome without empty state?
From: Andrzej Krzemienski (akrzemi1_at_[hidden])
Date: 2017-05-26 21:55:13


2017-05-26 17:59 GMT+02:00 Niall Douglas via Boost <boost_at_[hidden]>:

> > Let me just recall her the suggestion from Peter made in the other
> thread.
> > Mybe have two types:
> > `expected<T, E>` does not have the empty state or default constructor --
> it
> > is used as function's return type
> > `prepare_expected<T, E>` is either T or E or Empty -- you use it inside
> > function to build expected<T, E>:
> >
> > ```
> > expected<T, E> f()
> > {
> > prepare_expected<T, E> ans;
> > // populate (or not) ans
> > return ans; // in this conversion you can do all sorts of checks
> > }
> > ```
> >
> > When it comes to converting from `prepare_expected<T, E>` to `expected<T,
> > E>`, you have plenty of choices: require manual conversion,
> narrow-contract
> > to be checked, a defensive if and throw... I am just not sure if
> > performance can be negatively impacted with this.
>
> I originally considered this design for Outcome's API.
>
> I ended up rejecting it because it's superfluous if you have correctly
> designed your expected/outcome/whatever in the first place.
>

What does "correctly" mean here?


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