<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Issue 1517: default_delete's default constructor should be trivial</title>
<meta property="og:title" content="Issue 1517: default_delete's default constructor should be trivial">
<meta property="og:description" content="C++ library issue. Status: C++11">
<meta property="og:url" content="https://cplusplus.github.io/LWG/issue1517.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++11">C++11</a> status.</em></p>
<h3 id="1517"><a href="lwg-defects.html#1517">1517</a>. default_delete's default constructor should be trivial</h3>
<p><b>Section:</b> 20.3.1.2.2 <a href="https://wg21.link/unique.ptr.dltr.dflt">[unique.ptr.dltr.dflt]</a> <b>Status:</b> <a href="lwg-active.html#C++11">C++11</a>
 <b>Submitter:</b> Daniel Kr&uuml;gler <b>Opened:</b> 2010-09-12 <b>Last modified:</b> 2016-01-28</p>
<p><b>Priority: </b>Not Prioritized
</p>
<p><b>View all other</b> <a href="lwg-index.html#unique.ptr.dltr.dflt">issues</a> in [unique.ptr.dltr.dflt].</p>
<p><b>View all issues with</b> <a href="lwg-status.html#C++11">C++11</a> status.</p>
<p><b>Discussion:</b></p>
<p>
The current working draft does specify the default c'tor of <code>default_delete</code> in a manner
to guarantee static initialization for default-constructed objects of static storage duration
as a consequence of the acceptance of the proposal <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2009/n2976.html">n2976</a>
but this paper overlooked the fact that the suggested declaration does not ensure that the type 
will be a trivial type. The type <code>default_delete</code> was always considered as a simple wrapper for 
calling <code>delete</code> or <code>delete[]</code>, respectivly and should be a trivial type.
</p>
<p>
In agreement with the new settled core language rules this easy to realize by just changing the declaration to
</p>
<blockquote><pre>
constexpr default_delete()<ins> = default</ins>;
</pre></blockquote>
<p>
This proposal also automatically solves the problem, that the semantics of the default constructor of the 
partial specialization <code>default_delete&lt;T[]&gt;</code> is not specified at all. By defaulting its default constructor 
as well, the semantics are well-defined.
</p>

<p><i>[
Post-Rapperswil
]</i></p>


<blockquote><p>
Moved to Tentatively Ready after 5 positive votes on c++std-lib.
</p></blockquote>

<p><i>[
Adopted at 2010-11 Batavia
]</i></p>




<p id="res-1517"><b>Proposed resolution:</b></p>
<p><i>The following wording changes are against N3126.</i></p>

<ol>
<li>Change the synopsis of the primary template definition of <code>default_delete</code> in [unique.ptr.dltr.dflt] as indicated:
<blockquote><pre>
namespace std {
  template &lt;class T&gt; struct default_delete {
    constexpr default_delete()<ins> = default</ins>;
    template &lt;class U&gt; default_delete(const default_delete&lt;U&gt;&amp;);
    void operator()(T*) const;
  };
}
</pre></blockquote>
</li>
<li>
Remove the prototype specification of the <code>default_delete</code> default constructor in [unique.ptr.dltr.dflt]/1. This
brings it in harmony with the style used in the partial specialization <code>default_delete&lt;T[]&gt;</code>. Since there are
neither implied nor explicit members, there is no possibility to misinterpret what the constructor does:
<blockquote><pre>
<del>constexpr default_delete();</del>
</pre><blockquote><p>
<del>1 <em>Effects</em>: Default constructs a <code>default_delete</code> object.</del>
</p></blockquote></blockquote>
</li>
<li>Change the synopsis of the partial specialization of <code>default_delete</code> in [unique.ptr.dltr.dflt1] as indicated:
<blockquote><pre>
namespace std {
  template &lt;class T&gt; struct default_delete&lt;T[]&gt; {
    constexpr default_delete()<ins> = default</ins>;
    void operator()(T*) const;
    template &lt;class U&gt; void operator()(U*) const = delete;
  };
}</pre></blockquote>
</li>
</ol>





</body>
</html>
