完成复制构造和赋值操作符
This commit is contained in:
@@ -94,8 +94,18 @@ namespace TinySTL{
|
|||||||
head.p = newNode();//add a dummy node
|
head.p = newNode();//add a dummy node
|
||||||
tail.p = head.p;
|
tail.p = head.p;
|
||||||
}
|
}
|
||||||
list(const list& list) = delete;
|
list(const list& l){
|
||||||
list& operator = (const list& list) = delete;
|
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(){
|
~list(){
|
||||||
for (; head != tail;){
|
for (; head != tail;){
|
||||||
auto temp = head++;
|
auto temp = head++;
|
||||||
|
|||||||
Reference in New Issue
Block a user