Boost logo

Boost :

From: Emil Dotchevski (emildotchevski_at_[hidden])
Date: 2020-05-31 18:13:27


On Sun, May 31, 2020 at 6:51 AM Bjorn Reese via Boost <boost_at_[hidden]>
wrote:
> I made a typo above. I meant to say std::get<I>.
>
> I am asking for a low-level API, not a bullet-proof API. If the latter
> is needed, then your existing pattern matching solution works just fine.
>
> The use of such a low-level API would look something like this:
>
> leaf::context<E0, E1> ctx;
> ctx.activate(); // I would like to avoid this though
>
> auto ret = foo();
> if (!ret)
> {
> switch (ctx.index(ret.error()))
> {
> case 0: // E0
> handle_E0(ctx.get<0>(ret.error()); break;
>
> case 1: // E1
> handle_E1(ctx.get<1>(ret.error()); break;
>
> default: // Unknown error type
> panic(); break;
> }
> }

I think you're essentially asking for access to this function, through
slightly different interface:
https://github.com/zajo/leaf/blob/develop/include/boost/leaf/handle_error.hpp?ts=4#L236
.


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