<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Issue 2819: Unspecified Return type: elements</title>
<meta property="og:title" content="Issue 2819: Unspecified Return type: elements">
<meta property="og:description" content="C++ library issue. Status: New">
<meta property="og:url" content="https://cplusplus.github.io/LWG/issue2819.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#New">New</a> status.</em></p>
<h3 id="2819"><a href="lwg-active.html#2819">2819</a>. Unspecified <i>Return type:</i> elements</h3>
<p><b>Section:</b> 32.2.5 <a href="https://wg21.link/thread.req.lockable">[thread.req.lockable]</a>, 32.6.4 <a href="https://wg21.link/thread.mutex.requirements">[thread.mutex.requirements]</a> <b>Status:</b> <a href="lwg-active.html#New">New</a>
 <b>Submitter:</b> Agust&iacute;n K-ballo Berg&eacute; <b>Opened:</b> 2016-11-12 <b>Last modified:</b> 2022-11-06</p>
<p><b>Priority: </b>3
</p>
<p><b>View all issues with</b> <a href="lwg-status.html#New">New</a> status.</p>
<p><b>Discussion:</b></p>
<p>
The current draft contains 14 occurrences of a <i>Return type:</i> clause.
That clause is not covered by 16.3.2.4 <a href="https://wg21.link/structure.specifications">[structure.specifications]</a> p3.
This was reported as editorial request <a href="https://github.com/cplusplus/draft/issues/266">#266</a>.
</p>

<p><i>[Issues Telecon 16-Dec-2016]</i></p>

<p>Priority 3; Jonathan to provide wording.</p>

<p><i>[12-May-2020, Jonathan provides wording to correct the <b>13</b> occurrences.]</i></p>


<p><strong>Previous resolution [SUPERSEDED]:</strong></p>
<blockquote class="note">
<p>This wording is relative to <a href="https://wg21.link/n4861">N4681</a>.</p>

<ol>
<li>
<p>Modify 32.2.5.3 <a href="https://wg21.link/thread.req.lockable.req">[thread.req.lockable.req]</a> as indicated:</p>
<blockquote>
<p>-1- A type <code>L</code> meets the <i>Cpp17Lockable</i> requirements
if it meets the <i>Cpp17BasicLockable</i> requirements
and the following expressions are
well-formed<ins>, have type <code>bool</code>,</ins>
and have the specified semantics
(<code>m</code> denotes a value of type <code>L</code>).
</p>
<p><code>m.try_lock()</code></p>
<blockquote>
<p>-2- <i>Effects:</i> [...]</p>
<p><del>-3- <i>Return type:</i> <code>bool</code>.</del></p>
<p>-4- <i>Returns:</i> <code>true</code> if the lock was acquired, <code>false</code> otherwise.</p>
</blockquote>
</blockquote>
</li>

<li>
<p>Modify 32.2.5.4 <a href="https://wg21.link/thread.req.lockable.timed">[thread.req.lockable.timed]</a> as indicated:</p>
<blockquote>
<p>-1- A type <code>L</code> meets the <i>Cpp17TimedLockable</i> requirements
if it meets the <i>Cpp17BasicLockable</i> requirements
and the following expressions are
well-formed<ins>, have type <code>bool</code>,</ins>
and have the specified semantics
(<code>m</code> denotes a value of type <code>L</code>,
<code>rel_time</code> denotes a value of an instantiation of
<code>duration</code> (30.5 <a href="https://wg21.link/time.duration">[time.duration]</a>),
and <code>abs_time</code> denotes a value of an instantiation of
<code>time_point</code> (30.6 <a href="https://wg21.link/time.point">[time.point]</a>)).
</p>
<p><code>m.try_lock_for(rel_time)</code></p>
<blockquote>
<p>-2- <i>Effects:</i> [...]</p>
<p><del>-3- <i>Return type:</i> <code>bool</code>.</del></p>
<p>-4- <i>Returns:</i> <code>true</code> if the lock was acquired, <code>false</code> otherwise.</p>
</blockquote>
<p><code>m.try_lock_until(abs_time)</code></p>
<blockquote>
<p>-2- <i>Effects:</i> [...]</p>
<p><del>-3- <i>Return type:</i> <code>bool</code>.</del></p>
<p>-4- <i>Returns:</i> <code>true</code> if the lock was acquired, <code>false</code> otherwise.</p>
</blockquote>
</blockquote>
</li>

<li>
<p>Modify 32.6.4.2 <a href="https://wg21.link/thread.mutex.requirements.mutex">[thread.mutex.requirements.mutex]</a> as indicated:</p>
<blockquote>
<p>-6- The expression <code>m.lock()</code> is
well-formed<ins>, has type <code>void</code>,</ins>
and has the following semantics:</p>
<blockquote>
<p>-7- <i>Preconditions:</i> [...]</p>
<p>-8- <i>Effects:</i> [...]</p>
<p>-9- <i>Postconditions:</i> [...]</p>
<p><del>-10- <i>Return type:</i> <code>void</code>.</del></p>
<p>-11- <i>Synchronization:</i> [...]</p>
<p>-12- <i>Throws:</i> [...]</p>
<p>-13- <i>Error conditions:</i> [...]</p>
</blockquote>
<p>-14- The expression <code>m.try_lock()</code> is
well-formed<ins>, has type <code>bool</code>,</ins>
and has the following semantics:</p>
<blockquote>
<p>-15- <i>Preconditions:</i> [...]</p>
<p>-16- <i>Effects:</i> [...]</p>
<p><del>-17- <i>Return type:</i> <code>bool</code>.</del></p>
<p>-18- <i>Returns:</i> <code>true</code> if ownership of the mutex was
obtained for the calling thread, otherwise <code>false</code>.</p>
<p>-19- <i>Synchronization:</i> [...]</p>
<p>-20- <i>Throws:</i> Nothing.</p>
</blockquote>
<p>-21- The expression <code>m.unlock()</code> is
well-formed<ins>, has type <code>void</code>,</ins>
and has the following semantics:</p>
<blockquote>
<p>-22- <i>Preconditions:</i> [...]</p>
<p>-23- <i>Effects:</i> [...]</p>
<p><del>-24- <i>Return type:</i> <code>void</code>.</del></p>
<p>-25- <i>Synchronization:</i> [...]</p>
<p>-26- <i>Throws:</i> Nothing.</p>
</blockquote>
</blockquote>
</li>

<li>
<p>Modify 32.6.4.3 <a href="https://wg21.link/thread.timedmutex.requirements">[thread.timedmutex.requirements]</a> as indicated:</p>
<blockquote>
<p>-1- The <i>timed mutex types</i> are the standard library types [...] </p>
<p>-2- The timed mutex types meet the <i>Cpp17TimedLockable</i> requirements
(32.2.5.4 <a href="https://wg21.link/thread.req.lockable.timed">[thread.req.lockable.timed]</a>).</p>
<p>-3- The expression <code>m.try_lock_for(rel_time)</code> is
well-formed<ins>, has type <code>bool</code>,</ins>
and has the following semantics:
</p>
<blockquote>
<p>-4- <i>Preconditions:</i> [...]</p>
<p>-5- <i>Effects:</i> [...]</p>
<p><del>-6- <i>Return type:</i> <code>bool</code>.</del></p>
<p>-7- <i>Returns:</i> <code>true</code> if the shared lock was acquired,
<code>false</code> otherwise.</p>
<p>-8- <i>Synchronization:</i> [...]</p>
<p>-9- <i>Throws:</i> [...]</p>
</blockquote>
<p>-10- The expression <code>m.try_lock_until(abs_time)</code> is
well-formed<ins>, has type <code>bool</code>,</ins>
and has the following semantics:
</p>
<blockquote>
<p>-11- <i>Preconditions:</i> [...]</p>
<p>-12- <i>Effects:</i> [...]</p>
<p><del>-13- <i>Return type:</i> <code>bool</code>.</del></p>
<p>-14- <i>Returns:</i> <code>true</code> if ownership was obtained,
otherwise <code>false</code>.</p>
<p>-15- <i>Synchronization:</i> [...]</p>
<p>-16- <i>Throws:</i> [...]</p>
</blockquote>
</blockquote>
</li>

<li>
<p>Modify 32.6.4.4 <a href="https://wg21.link/thread.sharedmutex.requirements">[thread.sharedmutex.requirements]</a> as indicated:</p>
<blockquote>
<p>-1- The standard library types <code>shared_mutex</code>
and  <code>shared_timed_mutex</code>
are <i>shared mutex types</i>. [...]
</p>
<p>-2- In addition to the exclusive lock ownership mode [...]</p>
<p>-3- The expression <code>m.lock_shared()</code> is
well-formed<ins>, has type <code>void</code>,</ins>
and has the following semantics:
</p>
<blockquote>
<p>-4- <i>Preconditions:</i> [...]</p>
<p>-5- <i>Effects:</i> [...]</p>
<p>-6- <i>Postconditions:</i> [...]</p>
<p><del>-7- <i>Return type:</i> <code>void</code>.</del></p>
<p>-8- <i>Synchronization:</i> [...]</p>
<p>-9- <i>Throws:</i> [...]</p>
<p>-10- <i>Error conditions:</i> [...]</p>
</blockquote>
<p>-11- The expression <code>m.unlock_shared()</code> is
well-formed<ins>, has type <code>void</code>,</ins>
and has the following semantics:
</p>
<blockquote>
<p>-12- <i>Preconditions:</i> [...]</p>
<p>-13- <i>Effects:</i> [...]</p>
<p><del>-14- <i>Return type:</i> <code>void</code>.</del></p>
<p>-15- <i>Synchronization:</i> [...]</p>
<p>-16- <i>Throws:</i> [...]</p>
</blockquote>
<p>-17- The expression <code>m.try_lock_shared()</code> is
well-formed<ins>, has type <code>bool</code>,</ins>
and has the following semantics:
</p>
<blockquote>
<p>-18- <i>Preconditions:</i> [...]</p>
<p>-19- <i>Effects:</i> [...]</p>
<p><del>-20- <i>Return type:</i> <code>bool</code>.</del></p>
<p>-21- <i>Returns:</i> <code>true</code> if the shared ownership lock was acquired,
<code>false</code> otherwise.</p>
<p>-22- <i>Synchronization:</i> [...]</p>
<p>-23- <i>Throws:</i> [...]</p>
</blockquote>
</blockquote>
</li>

<li>
<p>Modify 32.6.4.5 <a href="https://wg21.link/thread.sharedtimedmutex.requirements">[thread.sharedtimedmutex.requirements]</a> as indicated:</p>
<blockquote>
<p>-1- The standard library type <code>shared_timed_mutex</code>
is a <i>shared timed mutex type</i>. [...]
</p>
<p>-2- The expression <code>m.try_lock_shared_for(rel_time)</code> is
well-formed<ins>, has type <code>bool</code>,</ins>
and has the following semantics:
</p>
<blockquote>
<p>-3- <i>Preconditions:</i> [...]</p>
<p>-4- <i>Effects:</i> [...]</p>
<p><del>-5- <i>Return type:</i> <code>bool</code>.</del></p>
<p>-6- <i>Returns:</i> <code>true</code> if the shared lock was acquired,
<code>false</code> otherwise.</p>
<p>-7- <i>Synchronization:</i> [...]</p>
<p>-8- <i>Throws:</i> [...]</p>
</blockquote>
<p>-9- The expression <code>m.try_lock_shared_until(abs_time)</code> is
well-formed<ins>, has type <code>bool</code>,</ins>
and has the following semantics:
</p>
<blockquote>
<p>-10- <i>Preconditions:</i> [...]</p>
<p>-11- <i>Effects:</i> [...]</p>
<p><del>-12- <i>Return type:</i> <code>bool</code>.</del></p>
<p>-13- <i>Returns:</i> <code>true</code> if the shared lock was acquired,
<code>false</code> otherwise.</p>
<p>-14- <i>Synchronization:</i> [...]</p>
<p>-15- <i>Throws:</i> [...]</p>
</blockquote>
</blockquote>
</li>
</ol>
</blockquote>

<p><i>[2022-11-06; Daniel comments and provides alternative wording]</i></p>

<p>
Now that we have the new element <i>Result:</i> specified in 16.3.2.4 <a href="https://wg21.link/structure.specifications">[structure.specifications]</a>,
we can simply replace all occurrences of the <i>Return type:</i> by this element.
</p>


<p id="res-2819"><b>Proposed resolution:</b></p>
<p>
This wording is relative to <a href="https://wg21.link/N4917" title=" Working Draft, Standard for Programming Language C++">N4917</a>.
</p>

<ol>
<li>
<p>Modify 32.2.5.3 <a href="https://wg21.link/thread.req.lockable.req">[thread.req.lockable.req]</a> as indicated:</p>
<blockquote>
<p>-1- A type <code>L</code> meets the <i>Cpp17Lockable</i> requirements
if it meets the <i>Cpp17BasicLockable</i> requirements
and the following expressions are
well-formed and have the specified semantics
(<code>m</code> denotes a value of type <code>L</code>).
</p>
<p><code>m.try_lock()</code></p>
<blockquote>
<p>-2- <i>Effects:</i> [...]</p>
<p>-3- <i><del>Return type</del><ins>Result</ins>:</i> <code>bool</code><del>.</del></p>
<p>-4- <i>Returns:</i> <code>true</code> if the lock was acquired, otherwise <code>false</code>.</p>
</blockquote>
</blockquote>
</li>

<li>
<p>Modify 32.2.5.4 <a href="https://wg21.link/thread.req.lockable.timed">[thread.req.lockable.timed]</a> as indicated:</p>
<blockquote>
<p>-1- A type <code>L</code> meets the <i>Cpp17TimedLockable</i> requirements
if it meets the <i>Cpp17Lockable</i> requirements
and the following expressions are
well-formed and have the specified semantics
(<code>m</code> denotes a value of type <code>L</code>,
<code>rel_time</code> denotes a value of an instantiation of
<code>duration</code> (30.5 <a href="https://wg21.link/time.duration">[time.duration]</a>),
and <code>abs_time</code> denotes a value of an instantiation of
<code>time_point</code> (30.6 <a href="https://wg21.link/time.point">[time.point]</a>)).
</p>
<p><code>m.try_lock_for(rel_time)</code></p>
<blockquote>
<p>-2- <i>Effects:</i> [...]</p>
<p>-3- <i><del>Return type</del><ins>Result</ins>:</i> <code>bool</code><del>.</del></p>
<p>-4- <i>Returns:</i> <code>true</code> if the lock was acquired, otherwise <code>false</code>.</p>
</blockquote>
<p><code>m.try_lock_until(abs_time)</code></p>
<blockquote>
<p>-5- <i>Effects:</i> [...]</p>
<p>-6- <i><del>Return type</del><ins>Result</ins>:</i> <code>bool</code><del>.</del></p>
<p>-7- <i>Returns:</i> <code>true</code> if the lock was acquired, otherwise <code>false</code>.</p>
</blockquote>
</blockquote>
</li>

<li>
<p>Modify 32.6.4.2.1 <a href="https://wg21.link/thread.mutex.requirements.mutex.general">[thread.mutex.requirements.mutex.general]</a> as indicated:</p>
<blockquote>
<p>-5- The expression <code>m.lock()</code> is
well-formed and has the following semantics:</p>
<blockquote>
<p>-6- <i>Preconditions:</i> [...]</p>
<p>-7- <i>Effects:</i> [...]</p>
<p>-8- <i>Synchronization:</i> [...]</p>
<p>-9- <i>Postconditions:</i> [...]</p>
<p>-10- <i><del>Return type</del><ins>Result</ins>:</i> <code>void</code><del>.</del></p>
<p>-11- <i>Throws:</i> [...]</p>
<p>-12- <i>Error conditions:</i> [...]</p>
</blockquote>
<p>-13- The expression <code>m.try_lock()</code> is
well-formed and has the following semantics:</p>
<blockquote>
<p>-14- <i>Preconditions:</i> [...]</p>
<p>-15- <i>Effects:</i> [...]</p>
<p>-16- <i>Synchronization:</i> [...]</p>
<p>-17- <i><del>Return type</del><ins>Result</ins>:</i> <code>bool</code><del>.</del></p>
<p>-18- <i>Returns:</i> <code>true</code> if ownership was obtained, otherwise <code>false</code>.</p>
<p>-19- <i>Throws:</i> Nothing.</p>
</blockquote>
<p>-20- The expression <code>m.unlock()</code> is
well-formed and has the following semantics:</p>
<blockquote>
<p>-21- <i>Preconditions:</i> [...]</p>
<p>-22- <i>Effects:</i> [...]</p>
<p>-23- <i><del>Return type</del><ins>Result</ins>:</i> <code>void</code><del>.</del></p>
<p>-24- <i>Synchronization:</i> [...]</p>
<p>-25- <i>Throws:</i> Nothing.</p>
</blockquote>
</blockquote>
</li>

<li>
<p>Modify 32.6.4.3.1 <a href="https://wg21.link/thread.timedmutex.requirements.general">[thread.timedmutex.requirements.general]</a> as indicated:</p>
<blockquote>
<p>-1- The <i>timed mutex types</i> are the standard library types [&hellip;] </p>
<p>-2- The expression <code>m.try_lock_for(rel_time)</code> is
well-formed and has the following semantics:
</p>
<blockquote>
<p>-3- <i>Preconditions:</i> [...]</p>
<p>-4- <i>Effects:</i> [...]</p>
<p>-5- <i>Synchronization:</i> [...]</p>
<p>-6- <i><del>Return type</del><ins>Result</ins>:</i> <code>bool</code><del>.</del></p>
<p>-7- <i>Returns:</i> <code>true</code> if ownership was obtained, otherwise <code>false</code>.</p>
<p>-8- <i>Throws:</i> [...]</p>
</blockquote>
<p>-9- The expression <code>m.try_lock_until(abs_time)</code> is
well-formed and has the following semantics:
</p>
<blockquote>
<p>-10- <i>Preconditions:</i> [...]</p>
<p>-11- <i>Effects:</i> [...]</p>
<p>-12- <i>Synchronization:</i> [...]</p>
<p>-13- <i><del>Return type</del><ins>Result</ins>:</i> <code>bool</code><del>.</del></p>
<p>-14- <i>Returns:</i> <code>true</code> if ownership was obtained, otherwise <code>false</code>.</p>
<p>-15- <i>Throws:</i> [...]</p>
</blockquote>
</blockquote>
</li>

<li>
<p>Modify 32.6.4.4.1 <a href="https://wg21.link/thread.sharedmutex.requirements.general">[thread.sharedmutex.requirements.general]</a> as indicated:</p>
<blockquote>
<p>-1- The standard library types <code>shared_mutex</code>
and  <code>shared_timed_mutex</code>
are <i>shared mutex types</i>. [...]
</p>
<p>-2- In addition to the exclusive lock ownership mode [...]</p>
<p>-3- The expression <code>m.lock_shared()</code> is
well-formed and has the following semantics:
</p>
<blockquote>
<p>-4- <i>Preconditions:</i> [...]</p>
<p>-5- <i>Effects:</i> [...]</p>
<p>-6- <i>Synchronization:</i> [...]</p>
<p>-7- <i>Postconditions:</i> [...]</p>
<p>-8- <i><del>Return type</del><ins>Result</ins>:</i> <code>void</code><del>.</del></p>
<p>-9- <i>Throws:</i> [...]</p>
<p>-10- <i>Error conditions:</i> [...]</p>
</blockquote>
<p>-11- The expression <code>m.unlock_shared()</code> is
well-formed and has the following semantics:
</p>
<blockquote>
<p>-12- <i>Preconditions:</i> [...]</p>
<p>-13- <i>Effects:</i> [...]</p>
<p>-14- <i><del>Return type</del><ins>Result</ins>:</i> <code>void</code><del>.</del></p>
<p>-15- <i>Synchronization:</i> [...]</p>
<p>-16- <i>Throws:</i> [...]</p>
</blockquote>
<p>-17- The expression <code>m.try_lock_shared()</code> is
well-formed and has the following semantics:
</p>
<blockquote>
<p>-18- <i>Preconditions:</i> [...]</p>
<p>-19- <i>Effects:</i> [...]</p>
<p>-20- <i>Synchronization:</i> [...]</p>
<p>-21- <i><del>Return type</del><ins>Result</ins>:</i> <code>bool</code><del>.</del></p>
<p>-22- <i>Returns:</i> <code>true</code> if the shared lock was acquired, otherwise <code>false</code>.</p>
<p>-23- <i>Throws:</i> [...]</p>
</blockquote>
</blockquote>
</li>

<li>
<p>Modify 32.6.4.5.1 <a href="https://wg21.link/thread.sharedtimedmutex.requirements.general">[thread.sharedtimedmutex.requirements.general]</a> as indicated:</p>
<blockquote>
<p>-1- The standard library type <code>shared_timed_mutex</code>
is a <i>shared timed mutex type</i>. [...]
</p>
<p>-2- The expression <code>m.try_lock_shared_for(rel_time)</code> is
well-formed and has the following semantics:
</p>
<blockquote>
<p>-3- <i>Preconditions:</i> [...]</p>
<p>-4- <i>Effects:</i> [...]</p>
<p>-5- <i>Synchronization:</i> [...]</p>
<p>-6- <i><del>Return type</del><ins>Result</ins>:</i> <code>bool</code><del>.</del></p>
<p>-7- <i>Returns:</i> <code>true</code> if the shared lock was acquired, otherwise
<code>false</code>.</p>
<p>-8- <i>Throws:</i> [...]</p>
</blockquote>
<p>-9- The expression <code>m.try_lock_shared_until(abs_time)</code> is
well-formed and has the following semantics:
</p>
<blockquote>
<p>-10- <i>Preconditions:</i> [...]</p>
<p>-11- <i>Effects:</i> [...]</p>
<p>-12- <i>Synchronization:</i> [...]</p>
<p>-13- <i><del>Return type</del><ins>Result</ins>:</i> <code>bool</code><del>.</del></p>
<p>-14- <i>Returns:</i> <code>true</code> if the shared lock was acquired, otherwise
<code>false</code>.</p>
<p>-15- <i>Throws:</i> [...]</p>
</blockquote>
</blockquote>
</li>
</ol>






</body>
</html>
