<div dir="ltr">On Wed, May 22, 2013 at 7:14 PM, Aleksandar Fabijanic <span dir="ltr"><<a href="mailto:aleskx@gmail.com" target="_blank">aleskx@gmail.com</a>></span> wrote:<br><div class="gmail_extra"><div class="gmail_quote">
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi,<br>
<br>
It was stated in this bug report<br>
<br>
<a href="http://llvm.org/bugs/show_bug.cgi?id=10248" target="_blank">http://llvm.org/bugs/show_bug.cgi?id=10248</a><br>
<br>
that specializing swap for non-std types in std namespace, although<br>
legal, is considered fragile. It is not entirely clear from the<br>
response why is that so.<br>
<br>
Can someone shed some light on this?<br></blockquote><div><br></div><div style>I'm not sure this is topical for cfe-dev, as it's just a question about C++.</div><div style><br></div><div style>C++ doesn't have partial specialization for templates, so it's not possible to define a std::swap for a user-define template. You could write an overload, except that it's not permitted to add overloads to namespace std.</div>
<div style><br></div><div style>On the bright side, ADL means that it's not necessary to put those in namespace std anyway, so long as people use swap properly (such that ADL is enabled).</div><div style><br></div><div style>
-- James</div><div style><br></div></div></div></div>