Boost logo

Boost :

Subject: Re: [boost] Outcome v2
From: Groke, Paul (paul.groke_at_[hidden])
Date: 2017-07-13 07:55:22


> Emil Dotchevski via Boost
> Sent: Donnerstag, 13. Juli 2017 00:27
>
> To clarify the clarification of the clarification, I _am_ interested in finding a
> way to express the equivalent of the Noexcept return throw_() without
> using TLS, and I don't insist on it being a free function; for example it would
> be sufficient if somehow I could just return r in case of an error, as long as it
> works regardless of what error type r might contain, and of course it should
> be reasonably efficient.

Have you thought about using a type-erased factory - like function<exception_ptr()> - as the error type?
Assuming that a) the function class implementation is small-object-optimized and b) that small-object buffer is large enough and c) the actual function object is very cheap to construct/copy/destruct... I think the speed could be acceptable. Still slower than copying some 2-3 ints, but probably faster than exception_ptr. This is purely a (somewhat) educated guess though, I haven't run any benchmarks.

Regards,
Paul


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