Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(22)

Unified Diff: styleguide/c++/c++11.html

Issue 2932053002: Use C++11 alignment primitives (Closed)
Patch Set: Fixes Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: styleguide/c++/c++11.html
diff --git a/styleguide/c++/c++11.html b/styleguide/c++/c++11.html
index 402e5c958d7387077ee0513de14c0e9ec3b6ad51..cf5378b7efa4915a87b5fa3df5bc24cb55ed41fc 100644
--- a/styleguide/c++/c++11.html
+++ b/styleguide/c++/c++11.html
@@ -78,6 +78,14 @@ change this file accordingly, linking to your discussion thread.</p>
</tr>
<tr>
+<td>alignas / alignof</td>
+<td><code>alignas(alignof(T)) char[10];</code></td>
+<td>Queries or specifies storage alignment.</td>
+<td><a href="http://en.cppreference.com/w/chttp://en.cppreference.com/w/cpp/language/alignas">alignas</a>, <a href="http://en.cppreference.com/w/cpp/language/alignof">alignof</a></td>
+<td><code>alignof()</code> can be used. <code>alignas()</code> must be used with care because it does not interact well with export and packing specifiers. If your declaration contains any other attributes, use <code>ALIGNAS()</code> from <code>base/compiler_specific.h</code> instead. <a href="https://codereview.chromium.org/2670873002/">Patch where this was discussed</a></td>
+</tr>
+
+<tr>
<td>Angle Bracket Parsing in Templates</td>
<td><code>&gt;&gt;</code> for <code>&gt; &gt;</code>, <code>&lt;::</code> for <code>&lt; ::</code></td>
<td>More intuitive parsing of template parameters</td>
@@ -610,6 +618,14 @@ std::move(t).f();&nbsp;&nbsp;// second</code></td>
</tr>
<tr>
+<td>Aligned storage</td>
+<td><code>std::aligned_storage&lt;10, 128&gt;</code></td>
+<td>Uninitialized storage for objects requiring specific alignment.</td>
+<td><a href="http://en.cppreference.com/w/cpp/types/aligned_storage">std::aligned_storage</a></td>
+<td>MSVC 2017's implementation does not align on boundaries greater than sizeof(double) = 8 bytes. Use <code>alignas(128) char foo[10];</code> instead. <a href="https://codereview.chromium.org/2932053002">Patch where this was discovered</a>.</td>
+</tr>
+
+<tr>
<td>Atomics</td>
<td><code>&lt;atomic&gt;</code></td>
<td>Fine-grained atomic types and operations</td>
@@ -769,11 +785,10 @@ std::move(t).f();&nbsp;&nbsp;// second</code></td>
<tr>
<td>Aligned Storage</td>
-<td><code>std::aligned_storage&lt;Size, Align&gt;::type</code><br />
-<code>std::alignment_of&lt;T&gt;</code>, <code>std::aligned_union&lt;Size, ...Types&gt;</code> <code>std::max_align_t</code></td>
+<td><code>std::alignment_of&lt;T&gt;</code>, <code>std::aligned_union&lt;Size, ...Types&gt;</code> <code>std::max_align_t</code></td>
<td>Declare uninitialized storage having a specified alignment, or determine alignments.</td>
-<td><a href="http://en.cppreference.com/w/cpp/types/aligned_storage">std::aligned_storage</a></td>
-<td><code>std::aligned_storage</code> and <code>std::aligned_union</code> are disallowed in google3 over concerns about compatibility with internal cross-compiling toolchains.</td>
+<td><a href="http://en.cppreference.com/w/cpp/types/aligned_union">std::aligned_union</a></td>
+<td><code>std::aligned_union</code> is disallowed in google3 over concerns about compatibility with internal cross-compiling toolchains. <code>std::aligned_storage</code> is on the disallowed list due to compatibility concerns.</td>
</tr>
<tr>

Powered by Google App Engine
This is Rietveld 408576698