<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Issue 2911: An is_aggregate type trait is needed</title>
<meta property="og:title" content="Issue 2911: An is_aggregate type trait is needed">
<meta property="og:description" content="C++ library issue. Status: C++17">
<meta property="og:url" content="https://cplusplus.github.io/LWG/issue2911.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++17">C++17</a> status.</em></p>
<h3 id="2911"><a href="lwg-defects.html#2911">2911</a>. An <code>is_aggregate</code> type trait is needed</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++17">C++17</a>
 <b>Submitter:</b> United States <b>Opened:</b> 2017-02-03 <b>Last modified:</b> 2020-09-06</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++17">C++17</a> status.</p>
<p><b>Discussion:</b></p>
<b>Addresses US 143</b>

<p>An <code>is_aggregate</code> type trait is needed. The emplace idiom is now common throughout the library, but typically relies 
on direct non-list initalization, which does not work for aggregates. With a suitable type trait, we could extend direct non-list-initlaization to perform aggregate-initalization on aggregate types.</p>
<p>Proposed change:</p>
<p>
Add a new row to Table 38:
</p>
<blockquote>
<pre>
template &lt;class T&gt;
struct is_aggregate;
</pre>
<p>
<code>T</code> is an aggregate type ([dcl.init.aggr])
<p/>
<code>remove_all_extents_t&lt;T&gt;</code> shall be a complete type, 
an array type, or (possibly <i>cv</i>-qualified) <code>void</code>.
</p>
</blockquote>

<p><i>[2017-02-26, Daniel comments and completes wording]</i></p>

<p>
The proposed wording is incomplete, since it doesn't update the <code>&lt;type_traits&gt;</code> header synopsis, also
ensuring that the corresponding <code>is_aggregate_v</code> variable template is defined.
</p>

<p><i>[2017-03-01, Daniel comments and adjusts wording]</i></p>

<p>
There is only one minor change performed, namely to mark the constant in the <code>is_aggregate_v</code> variable 
template as <code>inline</code> following the LWG preferences for "full inline" bullet list (B2) from
<a href="https://wg21.link/p0607r0">P0607R0</a>.
</p>

<p><i>[2017-03-03, Kona, LEWG]</i></p>

<p>
No interest in doing the is-list-initializable <em>instead</em>. No objection to getting that proposal also.
<p/>
Want this for C++17?
<p/>
SF | F | N | A | SA
<p/>
2  | 8 | 1 | 3 | 0
<p/>
Want this for C++20?
<p/>
SF | F | N | A | SA
<p/>
6  | 5 | 2 | 0 | 0
<p/>
Remember to correct the wording to: "<code>remove_all_extents_t&lt;T&gt;</code> shall be a complete type or <i>cv</i>-<code>void</code>."
</p>

<p><i>[2017-03-03, Daniel updates wording]</i></p>

<p>
In sync with existing writing, this was changed to "<code>remove_all_extents_t&lt;T&gt;</code> shall be a complete type or <i>cv</i> <code>void</code>"
</p>
<p><i>[Kona 2017-03-02]</i></p>

<p>Accepted as Immediate to resolve NB comment.</p>
<p>This will require a new complier intrinsic; Alisdair checked with Core and they're OK with that</p>


<p id="res-2911"><b>Proposed resolution:</b></p>
<p>This wording is relative to <a href="https://wg21.link/n4640">N4640</a>.</p>
<ol>
<li><p>Modify 21.3.3 <a href="https://wg21.link/meta.type.synop">[meta.type.synop]</a>, <code>&lt;type_traits&gt;</code> header synopsis, as indicated:</p>

<blockquote><pre>
<i>// 20.15.4.3, type properties</i>
[&hellip;]
template &lt;class T&gt; struct is_final;
<ins>template &lt;class T&gt; struct is_aggregate;</ins>

[&hellip;]
<i>// 20.15.4.3, type properties</i>
[&hellip;]
template &lt;class T&gt; constexpr bool is_final_v
  = is_final&lt;T&gt;::value;
<ins>template &lt;class T&gt; inline constexpr bool is_aggregate_v
  = is_aggregate&lt;T&gt;::value;</ins>
[&hellip;]
</pre></blockquote>
</li>

<li><p>Add a new row to Table 42 &mdash; "Type property predicates":</p>
<blockquote><pre>
<ins>template &lt;class T&gt; struct is_aggregate;</ins>
</pre>
<p>
<ins><code>T</code> is an aggregate type (9.5.2 <a href="https://wg21.link/dcl.init.aggr">[dcl.init.aggr]</a>)</ins>
<p/>
<ins><code>remove_all_extents_t&lt;T&gt;</code> shall be a complete type or <i>cv</i> <code>void</code>.</ins>
</p>
</blockquote>
</li>
</ol>





</body>
</html>
