In C++11 you can use the auto keyword to declare the temporary variable, for example:
auto temp = a;
a = b;
b = temp;
That works for all types and classes that support the assignment operator.
For numeric types that support the exclusive-or operator you can use the following trick:
a = a ^ b;
b = a ^ b;
a = a ^ b;
For an explanation see:
http://en.wikipedia.org/wiki/XOR_swap_algorithm[
^]