Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
可能产生循环引用导致内存泄漏
这个构造函数有什么可以改进的?
使用初始化列表构造 减少一次拷贝 并把prev内存清空,避免空悬指针
// 应输出多少次?为什么少了?
shared_ptr会导致循环引用,因此List被解析以后,Node不会被释放。
// 为什么删除拷贝赋值函数也不出错?
因为定义了移动赋值函数,编译器在无拷贝赋值的情况下会尝试移动赋值
void print(List const &lst) { // 有什么值得改进的?
//改为传const引用,因为打印不涉及到对象的控制权,也无需修改对象属性