Skip to content

Commit 3b928c3

Browse files
jensmaurertkoeppe
authored andcommitted
P2927R3 Inspecting exception_ptr
1 parent aba6104 commit 3b928c3

File tree

1 file changed

+31
-1
lines changed

1 file changed

+31
-1
lines changed

source/support.tex

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -665,6 +665,7 @@
665665
#define @\defnlibxname{cpp_lib_erase_if}@ 202002L
666666
// also in \libheader{string}, \libheader{deque}, \libheader{forward_list}, \libheader{list}, \libheader{vector}, \libheader{map}, \libheader{set}, \libheader{unordered_map},
667667
// \libheader{unordered_set}
668+
#define @\defnlibxname{cpp_lib_exception_ptr_cast}@ 202506L // also in \libheader{exception}
668669
#define @\defnlibxname{cpp_lib_exchange_function}@ 201304L // freestanding, also in \libheader{utility}
669670
#define @\defnlibxname{cpp_lib_execution}@ 201902L // also in \libheader{execution}
670671
#define @\defnlibxname{cpp_lib_expected}@ 202211L // also in \libheader{expected}
@@ -3864,6 +3865,8 @@
38643865
constexpr exception_ptr current_exception() noexcept;
38653866
[[noreturn]] constexpr void rethrow_exception(exception_ptr p);
38663867
template<class E> constexpr exception_ptr make_exception_ptr(E e) noexcept;
3868+
template<class E> const E* exception_ptr_cast(const exception_ptr& p) noexcept;
3869+
template<class E> void exception_ptr_cast(const exception_ptr&&) = delete;
38673870

38683871
template<class T> [[noreturn]] constexpr void throw_with_nested(T&& t);
38693872
template<class E> constexpr void rethrow_if_nested(const E& e);
@@ -4143,7 +4146,8 @@
41434146
For purposes of determining the presence of a data race, operations on
41444147
\tcode{exception_ptr} objects shall access and modify only the
41454148
\tcode{exception_ptr} objects themselves and not the exceptions they refer to.
4146-
Use of \tcode{rethrow_exception} on \tcode{exception_ptr} objects that refer to
4149+
Use of \tcode{rethrow_exception} or \tcode{exception_ptr_cast}
4150+
on \tcode{exception_ptr} objects that refer to
41474151
the same exception object shall not introduce a data race.
41484152
\begin{note}
41494153
If
@@ -4240,6 +4244,32 @@
42404244
\end{note}
42414245
\end{itemdescr}
42424246

4247+
\indexlibraryglobal{exception_ptr_cast}%
4248+
\begin{itemdecl}
4249+
template<class E> const E* exception_ptr_cast(const exception_ptr& p) noexcept;
4250+
\end{itemdecl}
4251+
4252+
\begin{itemdescr}
4253+
\pnum
4254+
\mandates
4255+
\tcode{E} is a cv-unqualified complete object type.
4256+
\tcode{E} is not an array type.
4257+
\tcode{E} is not a pointer or pointer-to-member type.
4258+
\begin{note}
4259+
When \tcode{E} is a pointer or pointer-to-member type,
4260+
a handler of type \tcode{const E\&} can match
4261+
without binding to the exception object itself.
4262+
\end{note}
4263+
4264+
\pnum
4265+
\returns
4266+
A pointer to the exception object referred to by \tcode{p},
4267+
if \tcode{p} is not null and
4268+
a handler of type \tcode{const E\&}
4269+
would be a match\iref{except.handle} for that exception object.
4270+
Otherwise, \tcode{nullptr}.
4271+
\end{itemdescr}
4272+
42434273
\rSec2[except.nested]{\tcode{nested_exception}}
42444274

42454275
\indexlibraryglobal{nested_exception}%

0 commit comments

Comments
 (0)