From a014a1754951543012797dc70b48d3d4cc350ed8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E6=99=93=E8=88=AA?= <1210603696@qq.com> Date: Sat, 29 Nov 2014 16:24:58 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E6=88=90=E5=A4=8D=E5=88=B6=E6=9E=84?= =?UTF-8?q?=E9=80=A0=E5=92=8C=E8=B5=8B=E5=80=BC=E6=93=8D=E4=BD=9C=E7=AC=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- TinySTL/List.h | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) 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++;