From 3b928c3dae70b987662298a520625e372e94adb4 Mon Sep 17 00:00:00 2001 From: Jens Maurer Date: Thu, 19 Jun 2025 21:02:16 +0200 Subject: [PATCH] P2927R3 Inspecting exception_ptr --- source/support.tex | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/source/support.tex b/source/support.tex index d845795893..269c350b00 100644 --- a/source/support.tex +++ b/source/support.tex @@ -665,6 +665,7 @@ #define @\defnlibxname{cpp_lib_erase_if}@ 202002L // also in \libheader{string}, \libheader{deque}, \libheader{forward_list}, \libheader{list}, \libheader{vector}, \libheader{map}, \libheader{set}, \libheader{unordered_map}, // \libheader{unordered_set} +#define @\defnlibxname{cpp_lib_exception_ptr_cast}@ 202506L // also in \libheader{exception} #define @\defnlibxname{cpp_lib_exchange_function}@ 201304L // freestanding, also in \libheader{utility} #define @\defnlibxname{cpp_lib_execution}@ 201902L // also in \libheader{execution} #define @\defnlibxname{cpp_lib_expected}@ 202211L // also in \libheader{expected} @@ -3864,6 +3865,8 @@ constexpr exception_ptr current_exception() noexcept; [[noreturn]] constexpr void rethrow_exception(exception_ptr p); template constexpr exception_ptr make_exception_ptr(E e) noexcept; + template const E* exception_ptr_cast(const exception_ptr& p) noexcept; + template void exception_ptr_cast(const exception_ptr&&) = delete; template [[noreturn]] constexpr void throw_with_nested(T&& t); template constexpr void rethrow_if_nested(const E& e); @@ -4143,7 +4146,8 @@ For purposes of determining the presence of a data race, operations on \tcode{exception_ptr} objects shall access and modify only the \tcode{exception_ptr} objects themselves and not the exceptions they refer to. -Use of \tcode{rethrow_exception} on \tcode{exception_ptr} objects that refer to +Use of \tcode{rethrow_exception} or \tcode{exception_ptr_cast} +on \tcode{exception_ptr} objects that refer to the same exception object shall not introduce a data race. \begin{note} If @@ -4240,6 +4244,32 @@ \end{note} \end{itemdescr} +\indexlibraryglobal{exception_ptr_cast}% +\begin{itemdecl} +template const E* exception_ptr_cast(const exception_ptr& p) noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\mandates +\tcode{E} is a cv-unqualified complete object type. +\tcode{E} is not an array type. +\tcode{E} is not a pointer or pointer-to-member type. +\begin{note} +When \tcode{E} is a pointer or pointer-to-member type, +a handler of type \tcode{const E\&} can match +without binding to the exception object itself. +\end{note} + +\pnum +\returns +A pointer to the exception object referred to by \tcode{p}, +if \tcode{p} is not null and +a handler of type \tcode{const E\&} +would be a match\iref{except.handle} for that exception object. +Otherwise, \tcode{nullptr}. +\end{itemdescr} + \rSec2[except.nested]{\tcode{nested_exception}} \indexlibraryglobal{nested_exception}%