提交 23fcf62b 创建 作者: Austin Clements's avatar Austin Clements

Standard C++ swap

上级 b76122e4
...@@ -12,6 +12,23 @@ namespace std { ...@@ -12,6 +12,23 @@ namespace std {
return static_cast<typename remove_reference<T>::type&&>(a); return static_cast<typename remove_reference<T>::type&&>(a);
} }
template<class T>
void
swap(T& a, T& b)
{
T tmp = move(a);
a = move(b);
b = move(tmp);
}
template<class T, size_t N>
void
swap(T (&a)[N], T (&b)[N])
{
for (size_t n = 0; n < N; n++)
swap(a[n], b[n]);
}
template<class A, class B> template<class A, class B>
struct pair { struct pair {
typedef A first_type; typedef A first_type;
......
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论