c++ template function

C++
template <class T>
void swap(T & lhs, T & rhs)
{
 T tmp = lhs;
 lhs = rhs;
 rhs = tmp;
}
Source

Also in C++: