Boost logo

Boost :

Subject: Re: [boost] Outcome v2
From: Groke, Paul (paul.groke_at_[hidden])
Date: 2017-07-14 07:27:25


> From: Emil Dotchevski via Boost
> Sent: Donnerstag, 13. Juli 2017 20:12
>
> > Have you thought about using a type-erased factory - like
> > function<exception_ptr()> - as the error type?
> >
>
> exception_ptr needs a memory allocation so that's a no-go.

Yes, exception_ptr needs a memory allocation. And atomic ref counting. Which is why I wrote factory function. The idea is that most of the time, you don't want/need to inspect the error, you just have to know that it happened and maybe be able to pass it on. Which can be very efficient if you return a factory.

I understand that this is far from perfect, but it's the best idea I have for a single type that can transport arbitrary error information.
(An alternative would be a functor that throws the exception when called, but AFAIK that will be even slower - much slower.)


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