@dustchens 在 从小白的视角探究 vector 第2章 中说:
Vector& operator=(const Vector &other) {
// 注意
if(this != &other) {
this->~Vector();
mSize_e = other.mSize_e;
mCapacity = other.mCapacity;
mDataPtr_e = static_cast<T *>(Alloc::allocate(sizeof(T) * mCapacity));
for (int i = 0; i < mSize_e; i++) {
mDataPtr_e[i] = other.mDataPtr_e[i];
}
}
return *this;
}
这一章节,需要大家思考这段内容,是否正确,为什么没有加上noexcept,noexcept为什么如此重要,需要后续单开一个章节去讲解