Why swap don't use Xor operation in C++
<p>I've learned that Xor operation can be used to implement effective swap function. like this:</p>

<pre><code>template&lt;class T&gt;
void swap(T&amp; a, T&amp; b)
{
    a = a^b;
    b = a^b;
    a = a^b;
}
</code></pre>

<p>But the implementation of swap all i can found on the internet is essentially like this:</p>

<pre><code>template&lt;class T&gt;
void swap(T&amp; a, T&amp; b)
{
    T temp(a);
    a = b;
    b = temp;
}
</code></pre>

<p>It seems that the compiler didn't generate the same code for the two form above because I tested it on VC++ 2010 and the first one is done the job more quickly(and is more quickly than std::swap). Is there portable or any other problem with first one? Feel free to correct any of my mistake cause i'm not an English native and not good at C++.</p>
