Skip to content

Commit 1008891

Browse files
jensmaurertkoeppe
authored andcommitted
P2401R0 Add a conditional noexcept specification to std::exchange
1 parent 8f900e1 commit 1008891

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

source/utilities.tex

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252

5353
// \ref{utility.exchange}, exchange
5454
template<class T, class U = T>
55-
constexpr T exchange(T& obj, U&& new_val);
55+
constexpr T exchange(T& obj, U&& new_val) noexcept(@\seebelow@);
5656

5757
// \ref{forward}, forward/move
5858
template<class T>
@@ -263,7 +263,7 @@
263263
\indexlibraryglobal{exchange}%
264264
\begin{itemdecl}
265265
template<class T, class U = T>
266-
constexpr T exchange(T& obj, U&& new_val);
266+
constexpr T exchange(T& obj, U&& new_val) noexcept(@\seebelow@);
267267
\end{itemdecl}
268268

269269
\begin{itemdescr}
@@ -275,6 +275,13 @@
275275
obj = std::forward<U>(new_val);
276276
return old_val;
277277
\end{codeblock}
278+
279+
\pnum
280+
\remarks
281+
The exception specification is equivalent to:
282+
\begin{codeblock}
283+
is_nothrow_move_constructible_v<T> && is_nothrow_assignable_v<T&, U>
284+
\end{codeblock}
278285
\end{itemdescr}
279286

280287

0 commit comments

Comments
 (0)