[PATCH 0/2]: Return optional<const _Ex&> from exception_ptr_cast

Jonathan Wakely jwakely@redhat.com
Fri Jul 3 11:45:18 GMT 2026


On Thu, 02 Jul 2026 at 14:22 +0200, Tomasz Kamiński wrote:
>This is split into two patches:
>* 1/2: Reorganizes headers to extract optional<T&> into separate
>       bits/optional_ref.hpp header,  with minimal dependencies
>* 2/2: Changes the exception_ptr_cast return type to optional<T&>
>
>For the functions that would expand the dependencies of the optiona_ref
>header, I have decided to define them out of line in <optional> header,
>and it's include is necessary in the program. See commit message of
>patch 2/2 for more details.
>
>Is this approach we want to take? I think we really cannot make value
>work, and transform/and_then would not be usable already without
><optional>.
>
>The benefit of having really minimal set of dependencies on optional_ref.hpp,
>is that it reduces changes of us reintroducing cyclce in the includes. I
>think there is high chance that bits/utility.h, bits/stl_iterator.h or
>bits/invoke.h may include <exception>.

Yes, I think this approach looks fine.

Other headers should probably avoid including all of <exception>, and
should include just the bits they need. But that might not be possible
in all case.



More information about the Libstdc++ mailing list