Skip to content

P2927R3 Inspecting exception_ptr #7976

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 31 additions & 1 deletion source/support.tex
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down Expand Up @@ -3868,6 +3869,8 @@
constexpr exception_ptr current_exception() noexcept;
[[noreturn]] constexpr void rethrow_exception(exception_ptr p);
template<class E> constexpr exception_ptr make_exception_ptr(E e) noexcept;
template<class E> const E* exception_ptr_cast(const exception_ptr& p) noexcept;
template<class E> void exception_ptr_cast(const exception_ptr&&) = delete;

template<class T> [[noreturn]] constexpr void throw_with_nested(T&& t);
template<class E> constexpr void rethrow_if_nested(const E& e);
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -4244,6 +4248,32 @@
\end{note}
\end{itemdescr}

\indexlibraryglobal{exception_ptr_cast}%
\begin{itemdecl}
template<class E> 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}%
Expand Down