<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Grösse von Array aus aligned_storages]]></title><description><![CDATA[<p>Wieso gibt folgendes Programm einmal &quot;1&quot; und zwei mal &quot;3&quot; aus?</p>
<pre><code class="language-cpp">int main()
{
  typedef std::aligned_storage&lt;1, 128&gt; type;
  typedef type array[3];
  struct strct {type a;type b;type c;};
  std::cout &lt;&lt; sizeof(type ) &lt;&lt; '\n';
  std::cout &lt;&lt; sizeof(array) &lt;&lt; '\n';
  std::cout &lt;&lt; sizeof(strct) &lt;&lt; '\n';
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/topic/314069/grösse-von-array-aus-aligned_storages</link><generator>RSS for Node</generator><lastBuildDate>Sat, 01 Aug 2026 20:08:57 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/314069.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 19 Feb 2013 19:03:19 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Grösse von Array aus aligned_storages on Tue, 19 Feb 2013 19:03:19 GMT]]></title><description><![CDATA[<p>Wieso gibt folgendes Programm einmal &quot;1&quot; und zwei mal &quot;3&quot; aus?</p>
<pre><code class="language-cpp">int main()
{
  typedef std::aligned_storage&lt;1, 128&gt; type;
  typedef type array[3];
  struct strct {type a;type b;type c;};
  std::cout &lt;&lt; sizeof(type ) &lt;&lt; '\n';
  std::cout &lt;&lt; sizeof(array) &lt;&lt; '\n';
  std::cout &lt;&lt; sizeof(strct) &lt;&lt; '\n';
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/2300044</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2300044</guid><dc:creator><![CDATA[elias strohratsch]]></dc:creator><pubDate>Tue, 19 Feb 2013 19:03:19 GMT</pubDate></item><item><title><![CDATA[Reply to Grösse von Array aus aligned_storages on Tue, 19 Feb 2013 19:48:29 GMT]]></title><description><![CDATA[<p>Weil du einmal ein Objekt und zweimal 3 Objekte hast? <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f615.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--confused_face"
      title=":confused:"
      alt="😕"
    /></p>
<p>Meinst du vielleicht <code>std::aligned_storage::type</code> ?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2300064</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2300064</guid><dc:creator><![CDATA[Nexus]]></dc:creator><pubDate>Tue, 19 Feb 2013 19:48:29 GMT</pubDate></item><item><title><![CDATA[Reply to Grösse von Array aus aligned_storages on Tue, 19 Feb 2013 20:27:23 GMT]]></title><description><![CDATA[<p>elias strohratsch schrieb:</p>
<blockquote>
<p>Wieso gibt folgendes Programm einmal &quot;1&quot; und zwei mal &quot;3&quot; aus?</p>
<pre><code class="language-cpp">int main()
{
  typedef std::aligned_storage&lt;1, 128&gt; type;
  typedef type array[3];
  struct strct {type a;type b;type c;};
  std::cout &lt;&lt; sizeof(type ) &lt;&lt; '\n';
  std::cout &lt;&lt; sizeof(array) &lt;&lt; '\n';
  std::cout &lt;&lt; sizeof(strct) &lt;&lt; '\n';
}
</code></pre>
</blockquote>
<p>1. Sofern deine Implementation keine Typen mit 128-Byte-Alignment unterstützt, ist das undefiniert.<br />
2. std::aligned_storage&lt;1, n&gt; sollte sowie immer die Größe 1 haben.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2300080</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2300080</guid><dc:creator><![CDATA[camper]]></dc:creator><pubDate>Tue, 19 Feb 2013 20:27:23 GMT</pubDate></item><item><title><![CDATA[Reply to Grösse von Array aus aligned_storages on Tue, 19 Feb 2013 21:54:47 GMT]]></title><description><![CDATA[<p><a class="plugin-mentions-user plugin-mentions-a" href="https://www.c-plusplus.net/forum/uid/12954">@Nexus</a>: Peinlich, ich habe wirklich das <code>::type</code> vergessen. <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f603.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--grinning_face_with_big_eyes"
      title=":D"
      alt="😃"
    /></p>
<p>camper schrieb:</p>
<blockquote>
<p>1. Sofern deine Implementation keine Typen mit 128-Byte-Alignment unterstützt, ist das undefiniert.</p>
</blockquote>
<p>?<br />
Ich dachte alle Typen, deren Alignment durch 128 teilbar sind, müssen sich darin speichern lassen, was in diesem Fall alle wären.</p>
<p>camper schrieb:</p>
<blockquote>
<p>2. std::aligned_storage&lt;1, n&gt; sollte sowie immer die Größe 1 haben.</p>
</blockquote>
<p>?<br />
Wenn du das ohne <code>::type</code> meinst: <code>struct alignas(16) empty{};</code> hat bei mir Grösse 16.<br />
Wenn das mit <code>::type</code> : Der Storage hat dann die Grösse 128.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2300104</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2300104</guid><dc:creator><![CDATA[elias strohratsch]]></dc:creator><pubDate>Tue, 19 Feb 2013 21:54:47 GMT</pubDate></item><item><title><![CDATA[Reply to Grösse von Array aus aligned_storages on Tue, 19 Feb 2013 22:21:42 GMT]]></title><description><![CDATA[<p>Meinte ::type<br />
Es wäre allerdings eher überrachend, falls aligned_storage keine leere Klasse sein sollte.</p>
<p>elias strohratsch schrieb:</p>
<blockquote>
<p>Wenn du das ohne <code>::type</code> meinst: <code>struct alignas(16) empty{};</code> hat bei mir Grösse 16.</p>
</blockquote>
<p>Das ist allerdings nicht zwingend identisch mit dem, was aligned_storage&lt;1,16&gt;::type liefert.</p>
<p>n3337 schrieb:</p>
<blockquote>
<p>Template<br />
template &lt;std::size_t Len, std::size_t Align = default-alignment &gt; struct aligned_storage;</p>
<p>Condition<br />
Len shall not be zero. Align shall be equal to alignof(T) for some type T or to default-alignment.</p>
<p>Comments<br />
The value of default-alignment shall be the most stringent alignment requirement for any C++ object type whose size is no greater than Len (3.9).<br />
The member typedef type shall be a POD type suitable for use as uninitialized storage for any object whose size is at most Len and whose alignment is a divisor of Align.</p>
</blockquote>
<p>Habe falsch gelesen. Es ist nicht garantiert, das sizeof(std::aligned_storage&lt;1, 128&gt;::type) 1 ist, eine vernünftige Implementierung sollte das allerdings m.M.n. so machen (da für alle Typen gilt: alignof(T)&lt;=sizeof(T))</p>
<p>Und falls deine Implementierung keine 128-Byte-aligned Typen kennt, kannst du unmöglich die angegebene Bedingung erfüllen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2300111</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2300111</guid><dc:creator><![CDATA[camper]]></dc:creator><pubDate>Tue, 19 Feb 2013 22:21:42 GMT</pubDate></item><item><title><![CDATA[Reply to Grösse von Array aus aligned_storages on Tue, 19 Feb 2013 23:11:22 GMT]]></title><description><![CDATA[<p>camper schrieb:</p>
<blockquote>
<p>elias strohratsch schrieb:</p>
<blockquote>
<p>Wenn du das ohne <code>::type</code> meinst: <code>struct alignas(16) empty{};</code> hat bei mir Grösse 16.</p>
</blockquote>
<p>Das ist allerdings nicht zwingend identisch mit dem, was aligned_storage&lt;1,16&gt;::type liefert.</p>
</blockquote>
<p>Es bezieht sich darauf, dass <code>std::aligned_storage&lt;1, n&gt;</code> auch als leere Klasse grösser als 1 sein darf.</p>
<p>camper schrieb:</p>
<blockquote>
<p>Es ist nicht garantiert, das sizeof(std::aligned_storage&lt;1, 128&gt;::type) 1 ist, eine vernünftige Implementierung sollte das allerdings m.M.n. so machen (da für alle Typen gilt: alignof(T)&lt;=sizeof(T))</p>
</blockquote>
<p>Ich hatte gehofft, dass das passiert, weil dann die Ausgabe meines Beispielprogramms interessant geworden wäre. Leider scheint bei GCC und bei Clang im Fall von aligned_storage immer Gleicheit zu gelten. Kannst du mir das vielleicht sagen?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2300121</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2300121</guid><dc:creator><![CDATA[elias strohratsch]]></dc:creator><pubDate>Tue, 19 Feb 2013 23:11:22 GMT</pubDate></item></channel></rss>