|
Boost : |
Subject: Re: [boost] [outcome] Review of Outcome
From: Peter Dimov (lists_at_[hidden])
Date: 2017-05-28 23:59:48
Niall Douglas wrote:
> ```
> result<void> function(std::vector<Foo> &a) noexcept
> {
> try
> {
> a.push_back(Foo());
> }
> BOOST_OUTCOME_CATCH_EXCEPTION_TO_RESULT
> }
> ```
>
> Here vector.push_back() might throw a std::bad_alloc. Under optimisation,
> the above code converts the throw of std::bad_alloc into a branch to early
> exit of an errored result<void>. So the exception throw and catch
> machinery is completely removed, and replaced with a fast branch. A very
> big win.
Unfortunately not. I expected this to be the case, but on the compilers I
tested recently, the throw is not removed. Apparently the compilers consider
the call to __cxa_throw observable behavior and never elide it. What
compiler did?
(I'll get back to the rest of your message later.)
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk