<?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[swap für eingenen Type korrekt implementieren]]></title><description><![CDATA[<p>Hallo,<br />
ich würde gerne eine eigene sawp Funktion für meine Klasse haben welche sich in einem eigenen Namespace befindet.<br />
nur wir macht man das korrekt?</p>
<ul>
<li>Als Memberfunction der Klasse ein swap(MyClass&amp; other)</li>
<li>eine eigene swap function, wenn dann in welchen Namespace</li>
<li>std::swap überladen</li>
<li>sonstiges</li>
</ul>
<p>vielen Dank für die Hilfe!</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/339860/swap-für-eingenen-type-korrekt-implementieren</link><generator>RSS for Node</generator><lastBuildDate>Sat, 11 Apr 2026 18:37:37 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/339860.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 04 Oct 2016 07:38:07 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to swap für eingenen Type korrekt implementieren on Tue, 04 Oct 2016 07:38:07 GMT]]></title><description><![CDATA[<p>Hallo,<br />
ich würde gerne eine eigene sawp Funktion für meine Klasse haben welche sich in einem eigenen Namespace befindet.<br />
nur wir macht man das korrekt?</p>
<ul>
<li>Als Memberfunction der Klasse ein swap(MyClass&amp; other)</li>
<li>eine eigene swap function, wenn dann in welchen Namespace</li>
<li>std::swap überladen</li>
<li>sonstiges</li>
</ul>
<p>vielen Dank für die Hilfe!</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2510449</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2510449</guid><dc:creator><![CDATA[kurze_frage]]></dc:creator><pubDate>Tue, 04 Oct 2016 07:38:07 GMT</pubDate></item><item><title><![CDATA[Reply to swap für eingenen Type korrekt implementieren on Tue, 04 Oct 2016 08:29:41 GMT]]></title><description><![CDATA[<p>Ich rate dir zur dritten Variante, dann wird das Ganze auch bei Templates funktionieren, welche auf std::swap setzen.<br />
Was hast du vor? Vielleicht brauchts auch nur einen Moveoperator/konstruktor.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2510453</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2510453</guid><dc:creator><![CDATA[Techel]]></dc:creator><pubDate>Tue, 04 Oct 2016 08:29:41 GMT</pubDate></item><item><title><![CDATA[Reply to swap für eingenen Type korrekt implementieren on Tue, 04 Oct 2016 08:30:15 GMT]]></title><description><![CDATA[<p><a href="http://en.cppreference.com/w/cpp/algorithm/swap" rel="nofollow">http://en.cppreference.com/w/cpp/algorithm/swap</a> schrieb:</p>
<blockquote>
<p>Specializations</p>
<p>std::swap may be specialized in namespace std for user-defined types, but such specializations are not found by ADL (the namespace std is not the associated namespace for the user-defined type). The expected way to make a user-defined type swappable is to provide a non-member function swap in the same namespace as the type: see Swappable for details.</p>
</blockquote>
]]></description><link>https://www.c-plusplus.net/forum/post/2510454</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2510454</guid><dc:creator><![CDATA[manni66]]></dc:creator><pubDate>Tue, 04 Oct 2016 08:30:15 GMT</pubDate></item><item><title><![CDATA[Reply to swap für eingenen Type korrekt implementieren on Tue, 04 Oct 2016 10:20:29 GMT]]></title><description><![CDATA[<p>danke für den Hilfstext manni66</p>
<p>so scheint es zu funktionieren</p>
<pre><code>namespace ns {
  class Foo {
    friend void swap (Foo&amp; a, Foo&amp;b) noexcept;
    // ...
    // Implementation Details tun nix zur Sache
  } ;

  void swap (Foo&amp; a, Foo&amp;b) noexcept ;
  //und natürlich auch irgendwo implementieren ...
}
</code></pre>
<p>damit ruft ein std::sort von einem vector&lt;Foo&gt; meine swap Implementation auf.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2510461</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2510461</guid><dc:creator><![CDATA[kurze_frage]]></dc:creator><pubDate>Tue, 04 Oct 2016 10:20:29 GMT</pubDate></item></channel></rss>