std::vector a, b; swap(a,b); template void swap(T& a, T& b){ T tmp(a); a= b; b= tmp; } template void swap(T& a, T& b){ T tmp(std::move(a)); a= std::move(b); b= std::move(tmp); }