如何在STL中实现交换功能?它是这么简单:
template<typename T> void swap(T& t1, T& t2) { T tmp(t1); t1=t2; t2=tmp; }
在其他帖子中,他们谈论为您自己的班级专门化这个功能.我为什么要这样做?为什么我不能使用这个std::swap功能?
std::swap
c++ templates swap
c++ ×1
swap ×1
templates ×1