This commit is contained in:
blueloveTH 2023-01-29 06:39:17 +08:00
parent 8008f131fb
commit b7e45ac2d2
2 changed files with 11 additions and 17 deletions

View File

@ -41,20 +41,16 @@ namespace pkpy{
} }
shared_ptr& operator=(const shared_ptr& other) { shared_ptr& operator=(const shared_ptr& other) {
if (this != &other) {
_dec_counter(); _dec_counter();
counter = other.counter; counter = other.counter;
_inc_counter(); _inc_counter();
}
return *this; return *this;
} }
shared_ptr& operator=(shared_ptr&& other) noexcept { shared_ptr& operator=(shared_ptr&& other) noexcept {
if (this != &other) {
_dec_counter(); _dec_counter();
counter = other.counter; counter = other.counter;
other.counter = nullptr; other.counter = nullptr;
}
return *this; return *this;
} }

View File

@ -99,13 +99,11 @@ namespace pkpy {
const PyVar& operator[](uint8_t i) const { return _args[i]; } const PyVar& operator[](uint8_t i) const { return _args[i]; }
ArgList& operator=(ArgList&& other) noexcept { ArgList& operator=(ArgList&& other) noexcept {
if(this != &other){
__tryRelease(); __tryRelease();
this->_args = other._args; this->_args = other._args;
this->_size = other._size; this->_size = other._size;
other._args = nullptr; other._args = nullptr;
other._size = 0; other._size = 0;
}
return *this; return *this;
} }