C++ Logo

std-proposals

Advanced search

Re: [std-proposals] Suggeting improvements to std::expected<T, std::exception_ptr>

From: Stewart Becker <stewart_at_[hidden]>
Date: Mon, 31 Mar 2025 19:07:51 +0100
On 31/03/2025 06:50, Pavel Vazharov wrote:
>
> 1. std::exception_ptr supported references (including rvalue
> references) for the value type,
> 2. std::exception_ptr::value() called
> std::rethrow_exception(error()) rather than throwing a
> std::bad_expected_access on error, and
> 3. std::exception_ptr<T, std::exception_ptr>::transform(f) and
> ::and_then(f) were noexcept. Completely noexcept is probably
> impossible, but it should be possible to wrap the
> transformation itself in try/catch, only throwing if the final
> copy/move of the returned result does so.
>
> I believe you meant `std::expected` instead of std::exception_ptr in
> the above points? (Only the second template parameter in the third
> point should be std::exception_ptr).

Ah yes. Sorry.

Received on 2025-03-31 18:07:56