void swap(int&a , int &b){ int t = a; a=b; b=t;}
void swap(int&a,int&b){ if (&a != &b) { a ^= b; b ^= a; a ^= b; }}
//伪代码void swap(char* a,int sizeofa,char*b,int sizeofb) { char temp[MAX] ={0}; strncpy(temp,sizeof(temp)-1,a) ; strncpy(a,sizeofa-1,b); strncpy(b,sizeofb-1,temp) ;}
void swap(char** a , char** b){ char* tmp = *a ; *a= *b; *b= tmp ;}
void swap(string& a , string&b){ string c(a) ; a=b; b=c;}
namespace std { template<typename T> void swap(T &a,T &b) { T temp(a); a = b; b = temp; }}
template<typename T>void swap(T& a,T&b) { T temp(std::move(a)); a = std::move(b); b = std::move(temp);}
template<typename T> decltype(auto) move(T&& param){ using ReturnType = remove_reference_t<T>&&; return static_cast<ReturnType>(param);}
编程资料 https://www.cppentry.com