Skip to content

Commit 3506bbe

Browse files
burblebeetkoeppe
authored andcommitted
LWG4172 unique_lock self-move-assignment is broken
Change suggested on the LWG reflector: Use parens instead of braced-init.
1 parent c17aba2 commit 3506bbe

File tree

1 file changed

+8
-19
lines changed

1 file changed

+8
-19
lines changed

source/threads.tex

Lines changed: 8 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -7634,7 +7634,7 @@
76347634
unique_lock& operator=(const unique_lock&) = delete;
76357635

76367636
unique_lock(unique_lock&& u) noexcept;
7637-
unique_lock& operator=(unique_lock&& u);
7637+
unique_lock& operator=(unique_lock&& u) noexcept;
76387638

76397639
// \ref{thread.lock.unique.locking}, locking
76407640
void lock();
@@ -7821,26 +7821,17 @@
78217821

78227822
\indexlibrarymember{operator=}{unique_lock}%
78237823
\begin{itemdecl}
7824-
unique_lock& operator=(unique_lock&& u);
7824+
unique_lock& operator=(unique_lock&& u) noexcept;
78257825
\end{itemdecl}
78267826

78277827
\begin{itemdescr}
78287828
\pnum
78297829
\effects
7830-
If \tcode{owns} calls \tcode{pm->unlock()}.
7831-
7832-
\pnum
7833-
\ensures
7834-
\tcode{pm == u_p.pm} and \tcode{owns == u_p.owns} (where \tcode{u_p} is the state of \tcode{u} just prior to this construction), \tcode{u.pm == 0} and \tcode{u.owns == false}.
7830+
Equivalent to: \tcode{unique_lock(std::move(u)).swap(*this)}
78357831

78367832
\pnum
7837-
\begin{note}
7838-
With a recursive mutex it is possible for both \tcode{*this} and \tcode{u} to own the same mutex before the assignment. In this case, \tcode{*this} will own the mutex after the assignment and \tcode{u} will not.
7839-
\end{note}
7840-
7841-
\pnum
7842-
\throws
7843-
Nothing.
7833+
\returns
7834+
\tcode{*this}.
78447835
\end{itemdescr}
78457836

78467837
\indexlibrarydtor{unique_lock}%
@@ -8327,13 +8318,11 @@
83278318
\begin{itemdescr}
83288319
\pnum
83298320
\effects
8330-
If \tcode{owns} calls \tcode{pm->unlock_shared()}.
8321+
Equivalent to: \tcode{shared_lock(std::move(sl)).swap(*this)}
83318322

83328323
\pnum
8333-
\ensures
8334-
\tcode{pm == sl_p.pm} and \tcode{owns == sl_p.owns} (where
8335-
\tcode{sl_p} is the state of \tcode{sl} just prior to this assignment),
8336-
\tcode{sl.pm == nullptr} and \tcode{sl.owns == false}.
8324+
\returns
8325+
\tcode{*this}.
83378326
\end{itemdescr}
83388327

83398328
\rSec4[thread.lock.shared.locking]{Locking}

0 commit comments

Comments
 (0)