From b6f17434b3fec9391ddff4f086582176c4be5f49 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 7d53612aad..0f588cac52 100644 --- a/source/support.tex +++ b/source/support.tex @@ -652,6 +652,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} @@ -3868,6 +3869,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); @@ -4147,7 +4150,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 @@ -4244,6 +4248,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}%