Boost logo

Boost :

Subject: Re: [boost] [outcome] Ternary logic -- need an example
From: Peter Dimov (lists_at_[hidden])
Date: 2017-05-18 14:50:20


Niall Douglas wrote:
> I did consider returning optionals which might be empty instead of
> throwing an exception.

That's not what I was saying. I was saying that for result<optional<T>>, if
you return by reference, you have to store an optional<T> object inside your
result. But if you return by value, you don't have to store an optional and
you can reuse your existing tag instead of adding the extra bool flag. That
is, use variant<T, none, error_code> instead of variant<optional<T>,
error_code>.

> > Also applies to other possible combinations such as expected<expected<T,
> > E1>, E2>, ...

Similarly, expected<expected<T, E1>, E2> can use a single variant<T, E1, E2>
for storage, if it can return by value. Return by reference requires it to
have an actual expected<T, E1> object to which to bind the returned
reference.


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