diff --git a/TinySTL/List.h b/TinySTL/List.h index 8c0c8b4..9b5c688 100644 --- a/TinySTL/List.h +++ b/TinySTL/List.h @@ -94,8 +94,18 @@ namespace TinySTL{ head.p = newNode();//add a dummy node tail.p = head.p; } - list(const list& list) = delete; - list& operator = (const list& list) = delete; + list(const list& l){ + head.p = newNode();//add a dummy node + tail.p = head.p; + for (auto node = l.head.p; node != l.tail.p; node = node->next) + push_back(node->data); + } + list& operator = (const list& l){ + if (this != &l){ + list(l).swap(*this); + } + return *this; + } ~list(){ for (; head != tail;){ auto temp = head++;