<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Issue 2196: Specification of is_*[copy/move]_[constructible/assignable] unclear for non-referencable types</title>
<meta property="og:title" content="Issue 2196: Specification of is_*[copy/move]_[constructible/assignable] unclear for non-referencable types">
<meta property="og:description" content="C++ library issue. Status: C++14">
<meta property="og:url" content="https://cplusplus.github.io/LWG/issue2196.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++14">C++14</a> status.</em></p>
<h3 id="2196"><a href="lwg-defects.html#2196">2196</a>. Specification of <code>is_*[copy/move]_[constructible/assignable]</code> unclear for non-referencable types</h3>
<p><b>Section:</b> 21.3.6.4 <a href="https://wg21.link/meta.unary.prop">[meta.unary.prop]</a> <b>Status:</b> <a href="lwg-active.html#C++14">C++14</a>
 <b>Submitter:</b> Daniel Kr&uuml;gler <b>Opened:</b> 2012-10-06 <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#meta.unary.prop">active issues</a> in [meta.unary.prop].</p>
<p><b>View all other</b> <a href="lwg-index.html#meta.unary.prop">issues</a> in [meta.unary.prop].</p>
<p><b>View all issues with</b> <a href="lwg-status.html#C++14">C++14</a> status.</p>
<p><b>Discussion:</b></p>

<p>
The pre-conditions for the type <code>is_copy_constructible</code> allow for template argument types were the language forbids 
forming a reference, namely <code>void</code> types and function types that have <em>cv</em>-qualifiers or a <em>ref</em>-qualifier.
<p/>
But the current wording in Table 49 defining the predicate condition,
</p>
<blockquote><p>
<code>is_constructible&lt;T, const T&amp;&gt;::value</code> is <code>true</code>.
</p></blockquote>
<p>
leaves it open whether such argument types would (a) create a well-formed instantiation of the trait template or if so (b) what
the outcome of the trait evaluation would be, as an example consider <code>std::is_copy_constructible&lt;void&gt;</code>.
<p/>
Current implementations differ, e.g. gcc accepts the instantiation and returns a false result, VS 2012
also accepts the instantiation but returns true.
<p/>
I would suggest that the wording clarifies that the instantiation would be valid for these types and I also would strongly 
prefer the outcome that the trait would always return false for these types. The latter seems rather natural
to me, because there is no way to define a variable of <code>void</code> type or of function type at all, so it would be surprising
to return a positive result for copy or move construction if no other construction could succeed. It is also not 
possible to assign to a any of these values (because there is no way to form lvalues of them), so the same argumentation 
can be applied to the <code>is_copy/move_assignable</code> traits as well.
<p/>
To reduce the amount of wording changes and repetitions, I suggest to define the term <em>referenceable type</em> in 
sub-clause  [definitions] or alternatively in the core language to describe types to which references
can be created via a typedef name. This definition corresponds to what the support concept <code>ReferentType</code> intended 
to describe during concept time.
<p/>
In addition, LWG issue <a href="lwg-defects.html#2101" title="Some transformation types can produce impossible types (Status: C++17)">2101</a><sup><a href="https://cplusplus.github.io/LWG/issue2101" title="Latest snapshot">(i)</a></sup> can also take advantage of the definition of a <em>referenceable type</em>.
<p/>
If the proposed resolution for LWG issue <a href="lwg-defects.html#2101" title="Some transformation types can produce impossible types (Status: C++17)">2101</a><sup><a href="https://cplusplus.github.io/LWG/issue2101" title="Latest snapshot">(i)</a></sup> would be accepted, there is an alternative solution possible
with the same effects. Now we would be able to use the now always well-formed instantiation of 
<code>std::add_lvalue_reference</code> to modify the current definition of <code>is_copy_constructible</code> to
</p>
<blockquote><p>
<code>is_constructible&lt;T,<br/> 
    typename add_lvalue_reference&lt;<br/> 
	typename add_const&lt;T&gt;::type&gt;::type&gt;::value</code> is true.
</p></blockquote>
<p>
and similar changes for the other affected traits.
</p>

<p><i>[2012-10 Portland: Move to Open]</i></p>

<p>
Referencable-type should be defined as "something that can be bound into a reference" or similar,
rather than a list of types where that is true today.  We can then provide the list of known types
that cannot be bound as examples that do not qualify in a note.
</p>

<p>
Otherwise we are happy with the wording.  AJM to redraft the definition and move to Review.
</p>

<p><i>[2013-04-18, Bristol]</i></p>




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

<ol>
<li><p>Add the following new definition to  [definitions] as indicated:</p>
<p><b>referenceable type</b> [defns.referenceable]</p>
<blockquote><p>
An object type, a function type that does not have <em>cv</em>-qualifiers or a <em>ref</em>-qualifier, or a reference type.
[<i>Note</i>: The term describes a type to which a reference can be created, including reference types. &mdash; <i>end note</i>]
</p></blockquote>
</li>

<li><p>Change Table 49 as indicated:</p>

<table border="1">
<caption>Table 49 &mdash; Type property predicates</caption>
<tr>
<th>Template</th>
<th>Condition</th>
<th>Preconditions</th>
</tr> 

<tr>
<td>
<code>template &lt;class T&gt;</code><br/>
<code>struct is_copy_constructible;</code>
</td>
<td>
<ins>For a referenceable type <code>T</code>, the same result as</ins><br/>
<code>is_constructible&lt;T,</code><br/>
<code>const T&amp;&gt;::value</code><del> is true</del><ins>, otherwise false</ins>.
</td>
<td>
<code>T</code> shall be a complete type,<br/>
(possibly <em>cv</em>-qualified) <code>void</code>, or an<br/> 
array of unknown bound.
</td>
</tr>

<tr>
<td>
<code>template &lt;class T&gt;</code><br/>
<code>struct is_move_constructible;</code>
</td>
<td>
<ins>For a referenceable type <code>T</code>, the same result as</ins><br/>
<code>is_constructible&lt;T,</code><br/>
<code>T&amp;&amp;&gt;::value</code><del> is true</del><ins>, otherwise false</ins>.
</td>
<td>
<code>T</code> shall be a complete type,<br/>
(possibly <em>cv</em>-qualified) <code>void</code>, or an<br/> 
array of unknown bound.
</td>
</tr>

<tr>
<td colspan="3" align="center">
<code>&hellip;</code>
</td>
</tr>

<tr>
<td>
<code>template &lt;class T&gt;</code><br/>
<code>struct is_copy_assignable;</code>
</td>
<td>
<ins>For a referenceable type <code>T</code>, the same result as</ins><br/>
<code>is_assignable&lt;T&amp;,</code><br/>
<code>const T&amp;&gt;::value</code><del> is true</del><ins>, otherwise false</ins>.
</td>
<td>
<code>T</code> shall be a complete type,<br/>
(possibly <em>cv</em>-qualified) <code>void</code>, or an<br/> 
array of unknown bound.
</td>
</tr>

<tr>
<td>
<code>template &lt;class T&gt;</code><br/>
<code>struct is_move_assignable;</code>
</td>
<td>
<ins>For a referenceable type <code>T</code>, the same result as</ins><br/>
<code>is_assignable&lt;T&amp;,</code><br/>
<code>T&amp;&amp;&gt;::value</code><del> is true</del><ins>, otherwise false</ins>.
</td>
<td>
<code>T</code> shall be a complete type,<br/>
(possibly <em>cv</em>-qualified) <code>void</code>, or an<br/> 
array of unknown bound.
</td>
</tr>

<tr>
<td colspan="3" align="center">
<code>&hellip;</code>
</td>
</tr>

<tr>
<td>
<code>template &lt;class T&gt;</code><br/>
<code>struct is_trivially_copy_constructible;</code>
</td>
<td>
<ins>For a referenceable type <code>T</code>, the same result as</ins><br/>
<code>is_trivially_constructible&lt;T,</code><br/>
<code>const T&amp;&gt;::value</code><del> is true</del><ins>, otherwise false</ins>.
</td>
<td>
<code>T</code> shall be a complete type,<br/>
(possibly <em>cv</em>-qualified) <code>void</code>, or an<br/> 
array of unknown bound.
</td>
</tr>

<tr>
<td>
<code>template &lt;class T&gt;</code><br/>
<code>struct is_trivially_move_constructible;</code>
</td>
<td>
<ins>For a referenceable type <code>T</code>, the same result as</ins><br/>
<code>is_trivially_constructible&lt;T,</code><br/>
<code>T&amp;&amp;&gt;::value</code><del> is true</del><ins>, otherwise false</ins>.
</td>
<td>
<code>T</code> shall be a complete type,<br/>
(possibly <em>cv</em>-qualified) <code>void</code>, or an<br/> 
array of unknown bound.
</td>
</tr>

<tr>
<td colspan="3" align="center">
<code>&hellip;</code>
</td>
</tr>

<tr>
<td>
<code>template &lt;class T&gt;</code><br/>
<code>struct is_trivially_copy_assignable;</code>
</td>
<td>
<ins>For a referenceable type <code>T</code>, the same result as</ins><br/>
<code>is_trivially_assignable&lt;T&amp;,</code><br/>
<code>const T&amp;&gt;::value</code><del> is true</del><ins>, otherwise false</ins>.
</td>
<td>
<code>T</code> shall be a complete type,<br/>
(possibly <em>cv</em>-qualified) <code>void</code>, or an<br/> 
array of unknown bound.
</td>
</tr>

<tr>
<td>
<code>template &lt;class T&gt;</code><br/>
<code>struct is_trivially_move_assignable;</code>
</td>
<td>
<ins>For a referenceable type <code>T</code>, the same result as</ins><br/>
<code>is_trivially_assignable&lt;T&amp;,</code><br/>
<code>T&amp;&amp;&gt;::value</code><del> is true</del><ins>, otherwise false</ins>.
</td>
<td>
<code>T</code> shall be a complete type,<br/>
(possibly <em>cv</em>-qualified) <code>void</code>, or an<br/> 
array of unknown bound.
</td>
</tr>

<tr>
<td colspan="3" align="center">
<code>&hellip;</code>
</td>
</tr>

<tr>
<td>
<code>template &lt;class T&gt;</code><br/>
<code>struct is_nothrow_copy_constructible;</code>
</td>
<td>
<ins>For a referenceable type <code>T</code>, the same result as</ins><br/>
<code>is_nothrow_constructible&lt;T,</code><br/>
<code>const T&amp;&gt;::value</code><del> is true</del><ins>, otherwise false</ins>.
</td>
<td>
<code>T</code> shall be a complete type,<br/>
(possibly <em>cv</em>-qualified) <code>void</code>, or an<br/> 
array of unknown bound.
</td>
</tr>

<tr>
<td>
<code>template &lt;class T&gt;</code><br/>
<code>struct is_nothrow_move_constructible;</code>
</td>
<td>
<ins>For a referenceable type <code>T</code>, the same result as</ins><br/>
<code>is_nothrow_constructible&lt;T,</code><br/>
<code>T&amp;&amp;&gt;::value</code><del> is true</del><ins>, otherwise false</ins>.
</td>
<td>
<code>T</code> shall be a complete type,<br/>
(possibly <em>cv</em>-qualified) <code>void</code>, or an<br/> 
array of unknown bound.
</td>
</tr>

<tr>
<td colspan="3" align="center">
<code>&hellip;</code>
</td>
</tr>

<tr>
<td>
<code>template &lt;class T&gt;</code><br/>
<code>struct is_nothrow_copy_assignable;</code>
</td>
<td>
<ins>For a referenceable type <code>T</code>, the same result as</ins><br/>
<code>is_nothrow_assignable&lt;T&amp;,</code><br/>
<code>const T&amp;&gt;::value</code><del> is true</del><ins>, otherwise false</ins>.
</td>
<td>
<code>T</code> shall be a complete type,<br/>
(possibly <em>cv</em>-qualified) <code>void</code>, or an<br/> 
array of unknown bound.
</td>
</tr>

<tr>
<td>
<code>template &lt;class T&gt;</code><br/>
<code>struct is_nothrow_move_assignable;</code>
</td>
<td>
<ins>For a referenceable type <code>T</code>, the same result as</ins><br/>
<code>is_nothrow_assignable&lt;T&amp;,</code><br/>
<code>T&amp;&amp;&gt;::value</code><del> is true</del><ins>, otherwise false</ins>.
</td>
<td>
<code>T</code> shall be a complete type,<br/>
(possibly <em>cv</em>-qualified) <code>void</code>, or an<br/> 
array of unknown bound.
</td>
</tr>

</table>

</li>
</ol>






</body>
</html>
