Jelajahi Sumber

add noexcept

Update safestl.h
blueloveTH 3 tahun lalu
induk
melakukan
6f33639fbd
2 mengubah file dengan 5 tambahan dan 5 penghapusan
  1. 2 2
      src/memory.h
  2. 3 3
      src/safestl.h

+ 2 - 2
src/memory.h

@@ -17,7 +17,7 @@ namespace pkpy{
         shared_ptr(const shared_ptr& other) : counter(other.counter) {
         shared_ptr(const shared_ptr& other) : counter(other.counter) {
             _inc_counter();
             _inc_counter();
         }
         }
-        shared_ptr(shared_ptr&& other) : counter(other.counter) {
+        shared_ptr(shared_ptr&& other) noexcept : counter(other.counter) {
             other.counter = nullptr;
             other.counter = nullptr;
         }
         }
         ~shared_ptr() {
         ~shared_ptr() {
@@ -49,7 +49,7 @@ namespace pkpy{
             return *this;
             return *this;
         }
         }
 
 
-        shared_ptr& operator=(shared_ptr&& other) {
+        shared_ptr& operator=(shared_ptr&& other) noexcept {
             if (this != &other) {
             if (this != &other) {
                 _dec_counter();
                 _dec_counter();
                 counter = other.counter;
                 counter = other.counter;

+ 3 - 3
src/safestl.h

@@ -113,14 +113,14 @@ namespace pkpy {
             }
             }
         }
         }
 
 
-        ArgList(ArgList&& other){
+        ArgList(ArgList&& other) noexcept {
             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;
         }
         }
 
 
-        ArgList(PyVarList&& other){
+        ArgList(PyVarList&& other) noexcept {
             __tryAlloc(other.size());
             __tryAlloc(other.size());
             for(uint8_t i=0; i<_size; i++){
             for(uint8_t i=0; i<_size; i++){
                 _args[i] = std::move(other[i]);
                 _args[i] = std::move(other[i]);
@@ -147,7 +147,7 @@ namespace pkpy {
         }
         }
 
 
         // overload = for &&
         // overload = for &&
-        ArgList& operator=(ArgList&& other){
+        ArgList& operator=(ArgList&& other) noexcept {
             if(this != &other){
             if(this != &other){
                 __tryRelease();
                 __tryRelease();
                 this->_args = other._args;
                 this->_args = other._args;