<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Issue 2577: {shared,unique}_lock should use std::addressof</title>
<meta property="og:title" content="Issue 2577: {shared,unique}_lock should use std::addressof">
<meta property="og:description" content="C++ library issue. Status: C++17">
<meta property="og:url" content="https://cplusplus.github.io/LWG/issue2577.html">
<meta property="og:type" content="website">
<meta property="og:image" content="http://cplusplus.github.io/LWG/images/cpp_logo.png">
<meta property="og:image:alt" content="C++ logo">
<style>
  p {text-align:justify}
  li {text-align:justify}
  pre code.backtick::before { content: "`" }
  pre code.backtick::after { content: "`" }
  blockquote.note
  {
    background-color:#E0E0E0;
    padding-left: 15px;
    padding-right: 15px;
    padding-top: 1px;
    padding-bottom: 1px;
  }
  ins {background-color:#A0FFA0}
  del {background-color:#FFA0A0}
  table.issues-index { border: 1px solid; border-collapse: collapse; }
  table.issues-index th { text-align: center; padding: 4px; border: 1px solid; }
  table.issues-index td { padding: 4px; border: 1px solid; }
  table.issues-index td:nth-child(1) { text-align: right; }
  table.issues-index td:nth-child(2) { text-align: left; }
  table.issues-index td:nth-child(3) { text-align: left; }
  table.issues-index td:nth-child(4) { text-align: left; }
  table.issues-index td:nth-child(5) { text-align: center; }
  table.issues-index td:nth-child(6) { text-align: center; }
  table.issues-index td:nth-child(7) { text-align: left; }
  table.issues-index td:nth-child(5) span.no-pr { color: red; }
  @media (prefers-color-scheme: dark) {
     html {
        color: #ddd;
        background-color: black;
     }
     ins {
        background-color: #225522
     }
     del {
        background-color: #662222
     }
     a {
        color: #6af
     }
     a:visited {
        color: #6af
     }
     blockquote.note
     {
        background-color: rgba(255, 255, 255, .10)
     }
  }
</style>
</head>
<body>
<hr>
<p><em>This page is a snapshot from the LWG issues list, see the <a href="lwg-active.html">Library Active Issues List</a> for more information and the meaning of <a href="lwg-active.html#C++17">C++17</a> status.</em></p>
<h3 id="2577"><a href="lwg-defects.html#2577">2577</a>. <code>{shared,unique}_lock</code> should use <code>std::addressof</code></h3>
<p><b>Section:</b> 32.6.5.4.2 <a href="https://wg21.link/thread.lock.unique.cons">[thread.lock.unique.cons]</a>, 32.6.5.5.2 <a href="https://wg21.link/thread.lock.shared.cons">[thread.lock.shared.cons]</a> <b>Status:</b> <a href="lwg-active.html#C++17">C++17</a>
 <b>Submitter:</b> Tim Song <b>Opened:</b> 2016-01-01 <b>Last modified:</b> 2017-07-30</p>
<p><b>Priority: </b>0
</p>
<p><b>View all other</b> <a href="lwg-index.html#thread.lock.unique.cons">issues</a> in [thread.lock.unique.cons].</p>
<p><b>View all issues with</b> <a href="lwg-status.html#C++17">C++17</a> status.</p>
<p><b>Discussion:</b></p>
<p>
So that they work with user-defined types that have overloaded unary <code>&amp;</code>.
</p>

<p><i>[2016-02, Issues Telecon]</i></p>

<p>
P0; move to Tentatively Ready.
</p>


<p id="res-2577"><b>Proposed resolution:</b></p>
<p>
This wording is relative to N4567.
</p>

<ol>
<li><p>Edit 32.6.5.4.2 <a href="https://wg21.link/thread.lock.unique.cons">[thread.lock.unique.cons]</a> as indicated:</p>

<blockquote>
<pre>
explicit unique_lock(mutex_type&amp; m);
</pre>
<blockquote>
<p>
[&hellip;]
<p/>
-5- <i>Postconditions</i>: <code>pm == <del>&amp;m</del><ins>addressof(m)</ins></code> and <code>owns == true</code>.
</p>
</blockquote>
<pre>
unique_lock(mutex_type&amp; m, defer_lock_t) noexcept;
</pre>
<blockquote>
<p>
[&hellip;]
<p/>
-7- <i>Postconditions</i>: <code>pm == <del>&amp;m</del><ins>addressof(m)</ins></code> and <code>owns == false</code>.
</p>
</blockquote>
<pre>
unique_lock(mutex_type&amp; m, try_to_lock_t);
</pre>
<blockquote>
<p>
[&hellip;]
<p/>
-10- <i>Postconditions</i>: <code>pm == <del>&amp;m</del><ins>addressof(m)</ins></code> and <code>owns == res</code>, 
where <code>res</code> is the value returned by the call to <code>m.try_lock()</code>.
</p>
</blockquote>
<pre>
unique_lock(mutex_type&amp; m, adopt_lock_t);
</pre>
<blockquote>
<p>
[&hellip;]
<p/>
-13- <i>Postconditions</i>: <code>pm == <del>&amp;m</del><ins>addressof(m)</ins></code> and <code>owns == true</code>.
<p/>
-14- <i>Throws</i>: Nothing.
</p>
</blockquote>
<pre>
template &lt;class Clock, class Duration&gt;
  unique_lock(mutex_type&amp; m, const chrono::time_point&lt;Clock, Duration&gt;&amp; abs_time);
</pre>
<blockquote>
<p>
[&hellip;]
<p/>
-17- <i>Postconditions</i>: <code>pm == <del>&amp;m</del><ins>addressof(m)</ins></code> and <code>owns == res</code>, 
where <code>res</code> is the value returned by the call to <code>m.try_lock_until(abs_time)</code>.
</p>
</blockquote>
<pre>
template &lt;class Rep, class Period&gt;
  unique_lock(mutex_type&amp; m, const chrono::duration&lt;Rep, Period&gt;&amp; rel_time);
</pre>
<blockquote>
<p>
[&hellip;]
<p/>
-20- <i>Postconditions</i>: <code>pm == <del>&amp;m</del><ins>addressof(m)</ins></code> and <code>owns == res</code>, 
where <code>res</code> is the value returned by the call to <code>m.try_lock_for(rel_time)</code>.
</p>
</blockquote>
</blockquote>

</li>

<li><p>Edit 32.6.5.5.2 <a href="https://wg21.link/thread.lock.shared.cons">[thread.lock.shared.cons]</a> as indicated:</p>

<blockquote>
<pre>
explicit shared_lock(mutex_type&amp; m);
</pre>
<blockquote>
<p>
[&hellip;]
<p/>
-5- <i>Postconditions</i>: <code>pm == <del>&amp;m</del><ins>addressof(m)</ins></code> and <code>owns == true</code>.
</p>
</blockquote>
<pre>
shared_lock(mutex_type&amp; m, defer_lock_t) noexcept;
</pre>
<blockquote>
<p>
[&hellip;]
<p/>
-7- <i>Postconditions</i>: <code>pm == <del>&amp;m</del><ins>addressof(m)</ins></code> and <code>owns == false</code>.
</p>
</blockquote>
<pre>
shared_lock(mutex_type&amp; m, try_to_lock_t);
</pre>
<blockquote>
<p>
[&hellip;]
<p/>
-10- <i>Postconditions</i>: <code>pm == <del>&amp;m</del><ins>addressof(m)</ins></code> and <code>owns == res</code> 
where <code>res</code> is the value returned by the call to <code>m.try_lock_shared()</code>.
</p>
</blockquote>
<pre>
shared_lock(mutex_type&amp; m, adopt_lock_t);
</pre>
<blockquote>
<p>
[&hellip;]
<p/>
-13- <i>Postconditions</i>: <code>pm == <del>&amp;m</del><ins>addressof(m)</ins></code> and <code>owns == true</code>.
</p>
</blockquote>
<pre>
template &lt;class Clock, class Duration&gt;
  shared_lock(mutex_type&amp; m,
              const chrono::time_point&lt;Clock, Duration&gt;&amp; abs_time);
</pre>
<blockquote>
<p>
[&hellip;]
<p/>
-16- <i>Postconditions</i>: <code>pm == <del>&amp;m</del><ins>addressof(m)</ins></code> and <code>owns == res</code> 
where <code>res</code> is the value returned by the call to <code>m.try_lock_shared_until(abs_time)</code>.
</p>
</blockquote>
<pre>
template &lt;class Rep, class Period&gt;
  shared_lock(mutex_type&amp; m,
              const chrono::duration&lt;Rep, Period&gt;&amp; rel_time);
</pre>
<blockquote>
<p>
[&hellip;]
<p/>
-19- <i>Postconditions</i>: <code>pm == <del>&amp;m</del><ins>addressof(m)</ins></code> and <code>owns == res</code> 
where <code>res</code> is the value returned by the call to <code>m.try_lock_shared_for(rel_time)</code>.
</p>
</blockquote>
</blockquote>

</li>
</ol>





</body>
</html>
