Boost logo

Boost :

From: Niall Douglas (s_sourceforge_at_[hidden])
Date: 2020-07-05 11:34:57


On 05/07/2020 03:29, Emil Dotchevski via Boost wrote:

>> Surely we test Boost with exceptions globally disabled in the regression
>> testing right?
>
> What Peter means is that boost::exception_ptr ought to support
> BOOST_NO_EXCEPTIONS. However, it does not, it never has.

I'll admit to surprise here. I always thought that one of the principle
reasons for Boost.Exception is exactly so that Boost can work well
enough with exceptions globally disabled.

I mean, I know I've seen bits of Boost in use on embedded platforms
where exceptions are globally disabled. It worked well enough. So you
surprise me that I was wrong here.

> It is not trivial to support it because its implementation has been
> complicated over the years; remember, it was added when there was no
> standard support for exception_ptr. And I've learned that I can't remove
> old features because there's code in the wild that uses them. I think this
> is the complete list of legacy features:
>
> - If there is standard support, it is able to wrap std::exception_ptr in a
> boost::exception_ptr.

So now I am confused. If std::exception_ptr works well enough with
exceptions globally disabled on all the major standard libraries, and
Boost.Exception is able to wrap that, what's the problem here?

Obviously, this is C++ 11 onwards only which Outcome requires in any
case, but I'm not seeing what the showstopper is here.

Coming back to your original question:

> Is there a way to configure Outcome so it does not use (boost)
> exception_ptr?

The outcome/boost_result.hpp is just a specialisation of
outcome::basic_result<> with Boost types, same as outcome/std_result.hpp
or outcome/experimental/status_result.hpp is.

You can absolutely configure your own outcome::basic_result<>
specialisation. If you simply want to remove the boost::exception_ptr
dependency, I'd suggest cloning outcome/boost_result.hpp into a new
file, and quite literally comment out the Boost.Exception stuff.
Obviously by doing this you'd lose support for result<T,
boost::exception_ptr>, but result<T, boost::system::error_code> should
work fine.

You're the first person to ever raise a need for a
outcome/boost_result.hpp which does not include Boost.Exception. If
there is at least one more person who would want that file split into
error code and exception_ptr editions, I am happy to oblige for after
this Boost release. Just open an issue at
https://github.com/ned14/outcome/issues.

Niall


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