diff --git a/TinySTL/List.h b/TinySTL/List.h index 4d32d27..3e7a501 100644 --- a/TinySTL/List.h +++ b/TinySTL/List.h @@ -132,7 +132,7 @@ namespace TinySTL{ void insert(iterator position, InputIterator first, InputIterator last); iterator erase(iterator position); iterator erase(iterator first, iterator last); - //void swap(List& x); + void swap(List& x); void clear(); //void splice(iterator position, list& x); //void splice(iterator position, list& x, iterator i); @@ -175,6 +175,9 @@ namespace TinySTL{ insert(position, *first); } } + public: + template + friend void swap(List& x, List& y); }; template void List::push_front(const value_type& val){ @@ -284,6 +287,15 @@ namespace TinySTL{ ++it; } } + template + void List::swap(List& x){ + TinySTL::swap(head.p, x.head.p); + TinySTL::swap(tail.p, x.tail.p); + } + template + void swap(List& x, List& y){ + x.swap(y); + } } #endif \ No newline at end of file