<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Issue 724: DefaultConstructible is not defined</title>
<meta property="og:title" content="Issue 724: DefaultConstructible is not defined">
<meta property="og:description" content="C++ library issue. Status: C++11">
<meta property="og:url" content="https://cplusplus.github.io/LWG/issue724.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="724"><a href="lwg-defects.html#724">724</a>. <code>DefaultConstructible</code> is not defined</h3>
<p><b>Section:</b> 16.4.4.2 <a href="https://wg21.link/utility.arg.requirements">[utility.arg.requirements]</a> <b>Status:</b> <a href="lwg-active.html#C++11">C++11</a>
 <b>Submitter:</b> Pablo Halpern <b>Opened:</b> 2007-09-12 <b>Last modified:</b> 2016-01-28</p>
<p><b>Priority: </b>Not Prioritized
</p>
<p><b>View other</b> <a href="lwg-index-open.html#utility.arg.requirements">active issues</a> in [utility.arg.requirements].</p>
<p><b>View all other</b> <a href="lwg-index.html#utility.arg.requirements">issues</a> in [utility.arg.requirements].</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 <code>DefaultConstructible</code> requirement is referenced in
several places in the August 2007 working draft
<a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2369.pdf">N2369</a>,
but is not defined anywhere.
</p>

<p><i>[
Bellevue:
]</i></p>


<blockquote>
<p>
Walking into the default&#47;value-initialization mess...
</p>
<p>
Why two lines? Because we need both expressions to be valid.
</p>
<p>
AJM not sure what the phrase "default constructed" means. This is
unfortunate, as the phrase is already used 24 times in the library!
</p>
<p>
Example: <code>const int</code> would not accept first line, but will accept the second.
</p>
<p>
This is an issue that must be solved by concepts, but we might need to solve it independantly first.
</p>
<p>
It seems that the requirements are the syntax in the proposed first
column is valid, but not clear what semantics we need.
</p>
<p>
A table where there is no post-condition seems odd, but appears to sum up our position best.
</p>
<p>
At a minimum an object is declared and is destructible.
</p>
<p>
Move to open, as no-one happy to produce wording on the fly.
</p>
</blockquote>

<p><i>[
2009-07-28 Reopened by Alisdair.  No longer solved by concepts.
]</i></p>


<p><i>[
2009-08-17 Daniel adds "[defaultconstructible]" to table title.  <a href="lwg-closed.html#408" title="Is vector&lt;reverse_iterator&lt;char*&gt; &gt; forbidden? (Status: NAD Editorial)">408</a><sup><a href="https://cplusplus.github.io/LWG/issue408" title="Latest snapshot">(i)</a></sup>
depends upon this issue.
]</i></p>


<p><i>[
2009-08-18 Alisdair adds:
]</i></p>


<blockquote>
<p>
Looking at the proposed table in this issue, it really needs two rows:
</p>

<blockquote>
<table border="1">
<caption>Table 33: <code>DefaultConstructible</code> requirements [defaultconstructible]</caption>
<tr>
<th>expression</th><th>post-condition</th>
</tr>

<tr>
<td><code>T t;</code></td><td><code>t</code> is default-initialized.</td>
</tr>

<tr>
<td><code>T{}</code></td><td>Object of type <code>T</code> is value-initialized.</td>
</tr>
</table>
</blockquote>

<p>
Note I am using the new brace-initialization syntax that is unambiguous
in all use cases (no most vexing parse.)
</p>
</blockquote>

<p><i>[
2009-10-03 Daniel adds:
]</i></p>


<blockquote>
<p>
The suggested definition <code>T{}</code> describing it as
value-initialization is wrong, because it belongs to list-initialization
which would - as the current rules are - always prefer a
initializer-list constructor over a default-constructor. I don't
consider this as an appropriate definition of
<code>DefaultConstructible</code>. My primary suggestion is to ask core,
whether the special case <code>T{}</code> (which also easily leads to
ambiguity situations for more than one initializer-list in a class)
would always prefer a default-constructor - if any - before considering
an initializer-list constructor or to provide another syntax form to
prefer value-initialization over list-initialization. If that fails I
would fall back to suggest to use the expression <code>T()</code> instead of
<code>T{}</code> with all it's disadvantages for the meaning of the
expression
</p>

<blockquote><pre>
T t();
</pre></blockquote>
</blockquote>

<p><i>[
2009-10 Santa Cruz:
]</i></p>


<blockquote><p>
Leave Open. Core is looking to make Alisdair's proposed
resolution correct.
</p></blockquote>

<p><i>[
2010-01-24 At Alisdair's request, moved his proposal into the proposed wording
section.  The old wording is preserved here:
]</i></p>


<blockquote>
<p>
In section 16.4.4.2 <a href="https://wg21.link/utility.arg.requirements">[utility.arg.requirements]</a>, before table 33, add the
following table:
</p>

<p style='text-align:center'>Table 33: <code>DefaultConstructible</code> 
requirements [defaultconstructible]</p>

<table border='0' cellspacing='0' cellpadding='0'
 style='border-collapse:collapse'>
 <tr>
  <td>
  <p style='text-align:center'>expression</p>
  </td>
  <td>
  <p style='text-align:center'>post-condition</p>
  </td>
 </tr>
 <tr>
  <td>
  <p><code>T t;</code><br/>
  <code>T()</code></p>
  </td>
  <td>
  <p><code>T</code> is <i>default constructed.</i></p>
  </td>
 </tr>
</table>

</blockquote>

<p><i>[
2010-02-04: Moved to Tentatively Ready after 5 positive votes on c++std-lib.
]</i></p>




<p><b>Rationale:</b></p>
<p><i>[
San Francisco:
]</i></p>

<blockquote><p>
We believe concepts will solve this problem
(<a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2774.pdf">N2774</a>).
</p></blockquote>

<p><i>[
Rationale is obsolete.
]</i></p>



<p id="res-724"><b>Proposed resolution:</b></p>
<p>
In section 16.4.4.2 <a href="https://wg21.link/utility.arg.requirements">[utility.arg.requirements]</a>, before table 33, add the
following table:
</p>

<blockquote>
<table border="1">
<caption>Table 33: <code>DefaultConstructible</code> requirements [defaultconstructible]</caption>
<tr>
<th>expression</th><th>post-condition</th>
</tr>

<tr>
<td><code>T t;</code></td><td>Object <code>t</code> is default-initialized.</td>
</tr>

<tr>
<td><code>T u{};</code></td><td>Object <code>u</code> is value-initialized.</td>
</tr>

<tr>
<td><code>T()<br/>T{}</code></td><td>A temporary object of type <code>T</code> is value-initialized.</td>
</tr>

</table>
</blockquote>






</body>
</html>
