<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Issue 1131: C++0x does not need alignment_of</title>
<meta property="og:title" content="Issue 1131: C++0x does not need alignment_of">
<meta property="og:description" content="C++ library issue. Status: C++11">
<meta property="og:url" content="https://cplusplus.github.io/LWG/issue1131.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="1131"><a href="lwg-defects.html#1131">1131</a>. C++0x does not need <code>alignment_of</code></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++11">C++11</a>
 <b>Submitter:</b> Niels Dekker <b>Opened:</b> 2009-06-01 <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++11">C++11</a> status.</p>
<p><b>Discussion:</b></p>
<p>
The <code>alignment_of</code> template is no longer necessary, now that the
core language will provide <code>alignof</code>. Scott Meyers raised this
issue at comp.std.c++,
<a href="http://groups.google.com/group/comp.std.c++/browse_thread/thread/9b020306e803f08a">C++0x: alignof vs. alignment_of</a>,
May 21, 2009.  In a reply, Daniel Kr&uuml;gler pointed out that
<code>alignof</code> was added to the working paper <i>after</i>
<code>alignment_of</code>. So it appears that <code>alignment_of</code> is only
part of the current Working Draft 
(<a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2009/n2857.pdf">N2857</a>)
because it is in TR1.
</p>
<p>
Having both <code>alignof</code> and <code>alignment_of</code> would cause
unwanted confusion. In general, I think TR1 functionality should not be
brought into C++0x if it is entirely redundant with other C++0x language
or library features.
</p>

<p><i>[
2009-11-16 Chris adds:
]</i></p>


<blockquote>
<p>
I would like to suggest the following new wording for this issue, based on
recent discussions. Basically this doesn't delete <code>alignment_of</code>, it just
makes it clear that it is just a wrapper for <code>alignof</code>. This deletes the
first part of the proposed resolution, changes the second part by leaving in
<code>alignof(T)</code> but changing the precondition and leaves the 3rd part
unchanged.
</p>

<p>
Suggested Resolution:
</p>

<blockquote>
<p>
Change the first row of Table 44 ("Type property queries"), from Type properties
21.3.6.4 <a href="https://wg21.link/meta.unary.prop">[meta.unary.prop]</a>:
</p>

<blockquote>
<table border="1">
<caption>Table 44 &mdash; Type property queries</caption>
<tr>
<td>
<code>template &lt;class T&gt; struct alignment_of;</code>
</td>
<td>
<code>alignof(T)</code>.<br/>
<i>Precondition:</i> <del><code>T</code> shall be a complete type, a reference type,
or an array of unknown bound, but shall not be a function type or (possibly
cv-qualified) <code>void</code>.</del> <ins><code>alignof(T)</code> shall be defined</ins>
</td>
</tr>

</table>
</blockquote>

<p>
Change text in Table 51 ("Other transformations"), from Other transformations
21.3.9.7 <a href="https://wg21.link/meta.trans.other">[meta.trans.other]</a>, as follows:
</p>

<blockquote>
<table border="1">
<caption>Table 51 &mdash; Other transformations</caption>
<tr>
<td>&hellip;<code>aligned_storage;</code></td>
<td>
<code>Len</code> shall not be zero. <code>Align</code> shall be equal to
<code><del>alignment_of&lt;T&gt;::value</del> <ins>alignof(T)</ins></code> for some
type <code>T</code> or to <i>default-alignment</i>.
</td>
<td>&hellip;</td>
</tr>
</table>
</blockquote>
</blockquote>
</blockquote>

<p><i>[
2010-01-30 Alisdair proposes that Chris' wording be moved into the proposed wording
section and tweaks it on the way.
]</i></p>


<blockquote>
<p>
Original proposed wording saved here:
</p>
<blockquote>
<p>
Remove from Header &lt;type_traits&gt; synopsis 21.3.3 <a href="https://wg21.link/meta.type.synop">[meta.type.synop]</a>:
</p>
<blockquote><pre>
<del>template &lt;class T&gt; struct alignment_of;</del>
</pre></blockquote>

<p>
Remove the first row of Table 44 ("Type property queries"), from
Type properties 21.3.6.4 <a href="https://wg21.link/meta.unary.prop">[meta.unary.prop]</a>:
</p>
<blockquote>
<table border="1">
<caption>Table 44 &mdash; Type property queries</caption>
<tr>
<td><del><code>template &lt;class T&gt; struct alignment_of;</code></del></td>
<td><del><code>alignof(T)</code>.</del><br/>
<del><i>Precondition:</i> <code>T</code> shall be a complete type, a reference
type, or an array of unknown bound, but shall not be a function type or
(possibly cv-qualified) <code>void</code>.</del>
</td>
</tr>
</table>
</blockquote>

<p>
Change text in Table 51 ("Other transformations"), from Other
transformations 21.3.9.7 <a href="https://wg21.link/meta.trans.other">[meta.trans.other]</a>, as follows:
</p>
<blockquote>
<table border="1">
<caption>Table 51 &mdash; Other transformations</caption>
<tr>
<td>&hellip;<code>aligned_storage;</code></td>
<td>
<code>Len</code> shall not be zero.  Align shall be equal to
<code><del>alignment_of&lt;T&gt;::value</del> <ins>alignof(T)</ins></code> for some
type <code>T</code> or to <i>default-alignment</i>.
</td>
<td>&hellip;</td>
</tr>
</table>
</blockquote>
</blockquote>
</blockquote>

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




<p id="res-1131"><b>Proposed resolution:</b></p>

<p>
Change the first row of Table 43 ("Type property queries"), from Type properties
21.3.6.4 <a href="https://wg21.link/meta.unary.prop">[meta.unary.prop]</a>:
</p>

<blockquote>
<table border="1">
<caption>Table 43 &mdash; Type property queries</caption>
<tr>
<td>
<code>template &lt;class T&gt; struct alignment_of;</code>
</td>
<td>
<code>alignof(T)</code>.<br/>
<i>Precondition:</i> <del><code>T</code> shall be a complete type, a reference type,
or an array of unknown bound, but shall not be a function type or (possibly
cv-qualified) <code>void</code>.</del> <ins><code>alignof(T)</code> is a valid
expression (7.6.2.6 <a href="https://wg21.link/expr.alignof">[expr.alignof]</a>)</ins>
</td>
</tr>

</table>
</blockquote>

<p>
Change text in Table 51 ("Other transformations"), from Other transformations
21.3.9.7 <a href="https://wg21.link/meta.trans.other">[meta.trans.other]</a>, as follows:
</p>

<blockquote>
<table border="1">
<caption>Table 51 &mdash; Other transformations</caption>
<tr>
<td>&hellip;<code>aligned_storage;</code></td>
<td>
<code>Len</code> shall not be zero. <code>Align</code> shall be equal to
<code><del>alignment_of&lt;T&gt;::value</del> <ins>alignof(T)</ins></code> for some
type <code>T</code> or to <i>default-alignment</i>.
</td>
<td>&hellip;</td>
</tr>
</table>
</blockquote>






</body>
</html>
