From: Andrey Semashev (andrey.semashev_at_[hidden])
Date: 2019-06-17 11:30:19


On 6/17/19 1:09 PM, dariomt--- via Boost wrote:
>>
>>> 2) How can I test proper support for std::current_exception() and
>>> std::rethrow_exception() if exceptions are disabled for the test?
>>
>> You should probably condition your test on BOOST_NO_EXCEPTIONS and make
>> the test no-op when exceptions are disabled.
>
> But that defeats the whole purpose of having tests.

Not really. You would still test the facilities when exceptions are
enabled. OTOH, I don't see why would anyone care about these components
when exceptions are disabled.

> I think I should at least use the type std::exception_ptr, and make sure
> the functions std::current_exception() and std::rethrow_exception() exist
> (even if I cannot test that they actually work as expected at runtime).
>
> I think the following should work, and at least the test tests something
> when exceptions are off:
>
> using std::exception_ptr;
> auto current = &std::current_exception;
> auto rethrow = &std::rethrow_exception;
>
> What do you think?

If it works, that would be fine by me. I don't disable exceptions and I
don't know whether the standard library components related to exceptions
stay available when exceptions are disabled. I wouldn't be surprised if
they don't (now or in a future version of the standard library
implementation). In any case, as I said, I don't see anyone using these
components when exceptions are disabled, so not much point in testing.