<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Issue 2551: [fund.ts.v2] "Exception safety" cleanup in library fundamentals required</title>
<meta property="og:title" content="Issue 2551: [fund.ts.v2] &quot;Exception safety&quot; cleanup in library fundamentals required">
<meta property="og:description" content="C++ library issue. Status: TS">
<meta property="og:url" content="https://cplusplus.github.io/LWG/issue2551.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#TS">TS</a> status.</em></p>
<h3 id="2551"><a href="lwg-defects.html#2551">2551</a>. [fund.ts.v2] "Exception safety" cleanup in library fundamentals required</h3>
<p><b>Section:</b> 8.2.1.1 <a href="https://cplusplus.github.io/fundamentals-ts/v2.html#memory.smartptr.shared.const">[fund.ts.v2::memory.smartptr.shared.const]</a> <b>Status:</b> <a href="lwg-active.html#TS">TS</a>
 <b>Submitter:</b> Daniel Kr&uuml;gler <b>Opened:</b> 2015-10-24 <b>Last modified:</b> 2017-07-30</p>
<p><b>Priority: </b>0
</p>
<p><b>View all issues with</b> <a href="lwg-status.html#TS">TS</a> status.</p>
<p><b>Discussion:</b></p>
<p><b>Addresses: fund.ts.v2</b></p>
<p>
Similar to LWG <a href="lwg-defects.html#2495" title="There is no such thing as an Exception Safety element (Status: C++17)">2495</a><sup><a href="https://cplusplus.github.io/LWG/issue2495" title="Latest snapshot">(i)</a></sup>, the current library fundamentals working paper refers to several "Exception safety" elements
without providing a definition for this element type.
</p>


<p id="res-2551"><b>Proposed resolution:</b></p>
<p>This wording is relative to <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2015/n4529.html">N4529</a>.</p>

<ol>
<li><p>Change 8.2.1.1 <a href="https://cplusplus.github.io/fundamentals-ts/v2.html#memory.smartptr.shared.const">[fund.ts.v2::memory.smartptr.shared.const]</a> as indicated:</p>

<blockquote>
<pre>
template&lt;class Y&gt; explicit shared_ptr(Y* p);
</pre>
<blockquote>
<p>
[&hellip;]
<p/>
-3- <i>Effects</i>: When <code>T</code> is not an array type, constructs a <code>shared_ptr</code> object that <em>owns</em> the pointer 
<code>p</code>. Otherwise, constructs a <code>shared_ptr</code> that <em>owns</em> <code>p</code> and a deleter of an unspecified type that 
calls <code>delete[] p</code>. <ins>If an exception is thrown, <code>delete p</code> is called when <code>T</code> is not an array type, 
<code>delete[] p</code> otherwise.</ins>
<p/>
[&hellip;]
<p/>
<del>-6- <i>Exception safety</i>: If an exception is thrown, <code>delete p</code> is called when <code>T</code> is not an array type, 
<code>delete[] p</code> otherwise.</del>
</p>
</blockquote>
<pre>
template&lt;class Y, class D&gt; shared_ptr(Y* p, D d);
template&lt;class Y, class D, class A&gt; shared_ptr(Y* p, D d, A a);
template &lt;class D&gt; shared_ptr(nullptr_t p, D d);
template &lt;class D, class A&gt; shared_ptr(nullptr_t p, D d, A a);
</pre>
<blockquote>
<p>
[&hellip;]
<p/>
-9- <i>Effects</i>: Constructs a <code>shared_ptr</code> object that <em>owns</em> the object <code>p</code> and the deleter <code>d</code>. 
The second and fourth constructors shall use a copy of <code>a</code> to allocate memory for internal use. <ins>If an exception is thrown, 
<code>d(p)</code> is called.</ins>
<p/>
[&hellip;]
<p/>
<del>-12- <i>Exception safety</i>: If an exception is thrown, <code>d(p)</code> is called.</del>
</p>
</blockquote>
<p>
[&hellip;]
</p>
<pre>
template&lt;class Y&gt; explicit shared_ptr(const weak_ptr&lt;Y&gt;&amp; r);
</pre>
<blockquote>
<p>
[&hellip;]
<p/>
-28- <i>Effects</i>: Constructs a <code>shared_ptr</code> object that <em>shares ownership</em> with <code>r</code> and stores a copy of 
the pointer stored in <code>r</code>. <ins>If an exception is thrown, the constructor has no effect.</ins>
<p/>
[&hellip;]
<p/>
<del>-31- <i>Exception safety</i>: If an exception is thrown, the constructor has no effect.</del>
</p>
</blockquote>
<pre>
template &lt;class Y, class D&gt; shared_ptr(unique_ptr&lt;Y, D&gt;&amp;&amp; r);
</pre>
<blockquote>
<p>
[&hellip;]
<p/>
-34- <i>Effects</i>: Equivalent to <code>shared_ptr(r.release(), r.get_deleter())</code> when <code>D</code> is not a reference type, 
otherwise <code>shared_ptr(r.release(), ref(r.get_deleter()))</code>. <ins>If an exception is thrown, the constructor has no effect.</ins>
<p/>
<del>-35- <i>Exception safety</i>: If an exception is thrown, the constructor has no effect.</del>
</p>
</blockquote>
</blockquote>

</li>
</ol>





</body>
</html>
