<?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[atomics noncopyable?]]></title><description><![CDATA[<p>Warum? <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f621.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--pouting_face"
      title=":rage:"
      alt="😡"
    /></p>
<pre><code class="language-cpp">atomic_bool a = static_cast&lt;bool&gt;(b);
</code></pre>
<p>WHYYYYYYYYYYY</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/309444/atomics-noncopyable</link><generator>RSS for Node</generator><lastBuildDate>Wed, 05 Aug 2026 06:30:44 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/309444.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 23 Oct 2012 07:48:17 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to atomics noncopyable? on Tue, 23 Oct 2012 07:48:17 GMT]]></title><description><![CDATA[<p>Warum? <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f621.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--pouting_face"
      title=":rage:"
      alt="😡"
    /></p>
<pre><code class="language-cpp">atomic_bool a = static_cast&lt;bool&gt;(b);
</code></pre>
<p>WHYYYYYYYYYYY</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2263103</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2263103</guid><dc:creator><![CDATA[Kellerautomat]]></dc:creator><pubDate>Tue, 23 Oct 2012 07:48:17 GMT</pubDate></item><item><title><![CDATA[Reply to atomics noncopyable? on Tue, 23 Oct 2012 08:34:21 GMT]]></title><description><![CDATA[<p>Einfach weils mich verwundert...</p>
<pre><code class="language-cpp">std::atomic_bool a(static_cast&lt;bool&gt;(b));
</code></pre>
<p>funktioniert.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2263116</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2263116</guid><dc:creator><![CDATA[Der Tobi]]></dc:creator><pubDate>Tue, 23 Oct 2012 08:34:21 GMT</pubDate></item><item><title><![CDATA[Reply to atomics noncopyable? on Tue, 23 Oct 2012 09:06:08 GMT]]></title><description><![CDATA[<p>Das ist es ja... Wozu muss ich das extra casten. So n Bullshit.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2263127</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2263127</guid><dc:creator><![CDATA[Kellerautomat]]></dc:creator><pubDate>Tue, 23 Oct 2012 09:06:08 GMT</pubDate></item><item><title><![CDATA[Reply to atomics noncopyable? on Tue, 23 Oct 2012 10:23:27 GMT]]></title><description><![CDATA[<p>Weil atomic weder kopiert noch verschoben werden kann.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2263161</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2263161</guid><dc:creator><![CDATA[camper]]></dc:creator><pubDate>Tue, 23 Oct 2012 10:23:27 GMT</pubDate></item><item><title><![CDATA[Reply to atomics noncopyable? on Tue, 23 Oct 2012 10:27:43 GMT]]></title><description><![CDATA[<p>Ja eben, das frage ich doch die ganze Zeit! Warum zur Hoelle ist atomic noncopyable? Das ergibt doch garkeinen Sinn!</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2263163</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2263163</guid><dc:creator><![CDATA[Kellerautomat]]></dc:creator><pubDate>Tue, 23 Oct 2012 10:27:43 GMT</pubDate></item><item><title><![CDATA[Reply to atomics noncopyable? on Tue, 23 Oct 2012 10:50:05 GMT]]></title><description><![CDATA[<p>Der Grund wird sein, dass std::atomic trivially copyable bleiben soll, um aus std::atomics zusammengesetzte structs wieder in std::atomic werfen zu können.</p>
<p>Übrigens sehe ich in Tobis Post keinen Cast, der in deinem Versuch nicht auch schon enthalten war.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2263172</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2263172</guid><dc:creator><![CDATA[seldon]]></dc:creator><pubDate>Tue, 23 Oct 2012 10:50:05 GMT</pubDate></item><item><title><![CDATA[Reply to atomics noncopyable? on Tue, 23 Oct 2012 10:57:02 GMT]]></title><description><![CDATA[<p>seldon schrieb:</p>
<blockquote>
<p>Der Grund wird sein, dass std::atomic trivially copyable bleiben soll, um aus std::atomics zusammengesetzte structs wieder in std::atomic werfen zu können.</p>
</blockquote>
<p>Da ist ein Widerspruch drin. Copy-ctor und copy-assignment von atomic-Typen sind immer deleted.</p>
<p>persönlich sehe ich nicht viel Sinn darin - atomics sind ihrem Zweck nach keine Value-Typen - diesen Typ kopierbar zu machen. Umgekehrt entsteht so nur eine Menge zusätzliches Fehlerpotential.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2263174</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2263174</guid><dc:creator><![CDATA[camper]]></dc:creator><pubDate>Tue, 23 Oct 2012 10:57:02 GMT</pubDate></item><item><title><![CDATA[Reply to atomics noncopyable? on Tue, 23 Oct 2012 11:00:00 GMT]]></title><description><![CDATA[<p>Kannst du ein Beispiel nennen, wie dadurch ein Fehler entstehen koennte? Bisher war das fuer mich immer nur laestig.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2263175</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2263175</guid><dc:creator><![CDATA[Kellerautomat]]></dc:creator><pubDate>Tue, 23 Oct 2012 11:00:00 GMT</pubDate></item><item><title><![CDATA[Reply to atomics noncopyable? on Tue, 23 Oct 2012 11:01:53 GMT]]></title><description><![CDATA[<p>Man braucht keinen Kopierkonstruktor oder Assignment-Operator, um trivially copyable zu sein. Siehe 9 (6) in C++11:</p>
<blockquote>
<p>A <em>trivially copyable class</em> is a class that:<br />
- has no non-trivial copy constructors (12.8),<br />
- has no non-trivial move construcots (12.8),<br />
- has no non-trivial copy assignment operators (13.5.3, 12.8),<br />
- has no non-trivial move assignment operators (13.5.3, 12.8), and<br />
- has a trivial destructor (12.4)</p>
</blockquote>
]]></description><link>https://www.c-plusplus.net/forum/post/2263178</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2263178</guid><dc:creator><![CDATA[seldon]]></dc:creator><pubDate>Tue, 23 Oct 2012 11:01:53 GMT</pubDate></item><item><title><![CDATA[Reply to atomics noncopyable? on Tue, 23 Oct 2012 11:13:14 GMT]]></title><description><![CDATA[<p>Der Copy-Ctor ist explizit deleted...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2263181</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2263181</guid><dc:creator><![CDATA[Kellerautomat]]></dc:creator><pubDate>Tue, 23 Oct 2012 11:13:14 GMT</pubDate></item><item><title><![CDATA[Reply to atomics noncopyable? on Tue, 23 Oct 2012 14:25:22 GMT]]></title><description><![CDATA[<p>seldon schrieb:</p>
<blockquote>
<p>Man braucht keinen Kopierkonstruktor oder Assignment-Operator, um trivially copyable zu sein. Siehe 9 (6) in C++11:</p>
<blockquote>
<p>A <em>trivially copyable class</em> is a class that:<br />
- has no non-trivial copy constructors (12.8),<br />
- has no non-trivial move construcots (12.8),<br />
- has no non-trivial copy assignment operators (13.5.3, 12.8),<br />
- has no non-trivial move assignment operators (13.5.3, 12.8), and<br />
- has a trivial destructor (12.4)</p>
</blockquote>
</blockquote>
<p>?<br />
Man <strong>darf</strong> keinen haben.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2263254</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2263254</guid><dc:creator><![CDATA[Sone]]></dc:creator><pubDate>Tue, 23 Oct 2012 14:25:22 GMT</pubDate></item><item><title><![CDATA[Reply to atomics noncopyable? on Tue, 23 Oct 2012 15:07:32 GMT]]></title><description><![CDATA[<p>Sone schrieb:</p>
<blockquote>
<p>Man <strong>darf</strong> keinen haben.</p>
</blockquote>
<p>Wo liest du das da?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2263265</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2263265</guid><dc:creator><![CDATA[dot]]></dc:creator><pubDate>Tue, 23 Oct 2012 15:07:32 GMT</pubDate></item><item><title><![CDATA[Reply to atomics noncopyable? on Tue, 23 Oct 2012 15:13:02 GMT]]></title><description><![CDATA[<p>Um seldons Zitate aus dem Standard noch zu vervollständigen:</p>
<p>Standard schrieb:</p>
<blockquote>
<p>12.8.12 A copy/move constructor for class X is trivial if it is not user-provided, [...]<br />
12.8.25 A copy/move assignment operator for class X is trivial if it is not user-provided, [...]</p>
<p>8.4.2.4 [...] A function is user-provided if it is user-declared and not explicitly defaulted or deleted on its first declaration.[...]</p>
</blockquote>
<p>Es gelten noch ein paar mehr Einschränkungen (hab ich weggelassen), aber ein =delete hindert eine Klasse nicht am trivial-sein.</p>
<p>Sone schrieb:</p>
<blockquote>
<p>?</p>
</blockquote>
<p>Womit wir wieder beim Thema wären: einfach mal die Fresse halten wenn man nix zu sagen hat.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2263268</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2263268</guid><dc:creator><![CDATA[standardbot]]></dc:creator><pubDate>Tue, 23 Oct 2012 15:13:02 GMT</pubDate></item><item><title><![CDATA[Reply to atomics noncopyable? on Tue, 23 Oct 2012 16:45:59 GMT]]></title><description><![CDATA[<p>dot schrieb:</p>
<blockquote>
<p>Sone schrieb:</p>
<blockquote>
<p>Man <strong>darf</strong> keinen haben.</p>
</blockquote>
<p>Wo liest du das da?</p>
</blockquote>
<p>Na da steht doch <em>-has no non-trivial copy ctor</em>, oder nicht? Wie darf er dann da sein?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2263292</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2263292</guid><dc:creator><![CDATA[Sone]]></dc:creator><pubDate>Tue, 23 Oct 2012 16:45:59 GMT</pubDate></item><item><title><![CDATA[Reply to atomics noncopyable? on Tue, 23 Oct 2012 17:27:22 GMT]]></title><description><![CDATA[<p>Genau das steht da. Die Klasse darf keinen <em>nichttrivialen</em> Copy Ctor haben...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2263300</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2263300</guid><dc:creator><![CDATA[dot]]></dc:creator><pubDate>Tue, 23 Oct 2012 17:27:22 GMT</pubDate></item><item><title><![CDATA[Reply to atomics noncopyable? on Tue, 23 Oct 2012 20:31:41 GMT]]></title><description><![CDATA[<p>dot schrieb:</p>
<blockquote>
<p>Genau das steht da. Die Klasse darf keinen <em>nichttrivialen</em> Copy Ctor haben...</p>
</blockquote>
<p>... Ja, und ein trivialer ist ein vom Compiler generierter. Und den meinte ich damit gar nicht. <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f642.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--slightly_smiling_face"
      title=":)"
      alt="🙂"
    /> Ich meinte, man darf keinen selbst definieren. <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f642.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--slightly_smiling_face"
      title=":)"
      alt="🙂"
    /></p>
<p>Aber ich glaube, das war auch scheiße formuliert, aus dem Kontext her erschließt es sich natürlich falsch <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>Thx</p>
<p>Edit: Eisflamme, du musst nicht auf mich aufpassen. <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f642.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--slightly_smiling_face"
      title=":)"
      alt="🙂"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/2263336</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2263336</guid><dc:creator><![CDATA[Sone]]></dc:creator><pubDate>Tue, 23 Oct 2012 20:31:41 GMT</pubDate></item><item><title><![CDATA[Reply to atomics noncopyable? on Tue, 23 Oct 2012 20:27:57 GMT]]></title><description><![CDATA[<p>Hat sich Dein Verständnisproblem mit dots Antwort jetzt erledigt oder nicht? Falls nicht, formulier doch um, falls doch, bedank Dich doch.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2263337</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2263337</guid><dc:creator><![CDATA[Eisflamme]]></dc:creator><pubDate>Tue, 23 Oct 2012 20:27:57 GMT</pubDate></item><item><title><![CDATA[Reply to atomics noncopyable? on Tue, 23 Oct 2012 21:11:28 GMT]]></title><description><![CDATA[<p>Ich hab jedenfalls nicht verstanden, warum man Copy Ctor explizit deleted.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2263341</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2263341</guid><dc:creator><![CDATA[Kellerautomat]]></dc:creator><pubDate>Tue, 23 Oct 2012 21:11:28 GMT</pubDate></item><item><title><![CDATA[Reply to atomics noncopyable? on Tue, 23 Oct 2012 22:27:48 GMT]]></title><description><![CDATA[<p>standardbot schrieb:</p>
<blockquote>
<p>Standard schrieb:</p>
<blockquote>
<p>8.4.2.4 [...] A function is user-provided if it is user-declared and not explicitly defaulted or deleted on its first declaration.[...]</p>
</blockquote>
<p>Es gelten noch ein paar mehr Einschränkungen (hab ich weggelassen), aber ein =delete hindert eine Klasse nicht am trivial-sein.</p>
</blockquote>
<p>Das Gegenteil ist der Fall. Das not bezieht sich nur auf &quot;explicitly defaulted&quot; (wäre &quot;explicitly defaulted or deleted&quot; zu negieren, lautete die Formulierung eher &quot;neither explicitly defaulted nor deleted&quot;).<br />
Übrigens auch eindeutig an der entsprechenden <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#1135" rel="nofollow">Lösung</a> erkennbar. Wäre es anders, könnte man jeden nicht-trivial kopierbaren Typen in ein struct packen, für dass alle speziellen Memberfunktionen deleted sind und erhielte etwas trivial Kopierbares (also etwas, auf das u.a. memcpy losgelassen werden kann), das ergibt keinen Sinn und würde auch einigen anderen Stellen des Standards widersprechen.</p>
<p>In jedem Fall sehe ich nicht, was triviale Kopierbarkeit im Zusammenhang mit atomics bringen soll. Man würde fast unvermeidlich 1.10/25-UB verursachen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2263351</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2263351</guid><dc:creator><![CDATA[camper]]></dc:creator><pubDate>Tue, 23 Oct 2012 22:27:48 GMT</pubDate></item><item><title><![CDATA[Reply to atomics noncopyable? on Wed, 24 Oct 2012 02:04:54 GMT]]></title><description><![CDATA[<p>camper schrieb:</p>
<blockquote>
<p>In jedem Fall sehe ich nicht, was triviale Kopierbarkeit im Zusammenhang mit atomics bringen soll.</p>
</blockquote>
<p>std::atomic verlangt, dass der verwaltete Typ trivially copyable ist (29.5 (1)).</p>
<p>Allerdings ist das, wo ich nochmal drüber nachdenke und <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2427.html" rel="nofollow">n2427</a> etwas genauer lese, vermutlich nicht das, worum es hier geht (mea culpa). Dieser Absatz lässt mich vermuten, dass es um die Regel der Fünf geht:</p>
<blockquote>
<p>We also provide the common fetch-and-modify operations. The fetch-and-modify functions return the original stored value. The original stored value is required for fetch-and-or and fetch-and-and because there is no means to compute to the original stored value from the new value and the modifying argument. In contrast to the functions, the fetch-and-modify assignment operators return the new value. We do this for consistency with normal assignment operators. <strong>Unlike normal C++ assignment operators, though, the atomic assignments return values rather than references, which is like C. The reason is that another thread might intervene between an assignment and a subsequent read. Rather than introduce this classic parallel programming bug, we return a value.</strong></p>
</blockquote>
<p>Aus diesem Grund gibt es keine normalen Zuweisungsoperatoren, und ohne Zuweisungsoperatoren sind Kopier- respektive Move-Konstruktoren eine gefährliche Idee.</p>
<p>Man könnte darüber nachdenken, ob std::atomic Zuweisungsoperatoren anbieten könnte, die einen std::atomic by-value zurückgeben (wofür man dann einen Kopierkonstruktor bräuchte), aber die Verwendung des Rückgabetyps wäre wohl eine ziemlich verwirrende Angelegenheit.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2263373</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2263373</guid><dc:creator><![CDATA[seldon]]></dc:creator><pubDate>Wed, 24 Oct 2012 02:04:54 GMT</pubDate></item></channel></rss>