blueloveTH 2 лет назад
Родитель
Сommit
a79d4e0d38
2 измененных файлов с 8 добавлено и 13 удалено
  1. 8 3
      include/pocketpy/expr.h
  2. 0 10
      include/pocketpy/vector.h

+ 8 - 3
include/pocketpy/expr.h

@@ -21,7 +21,7 @@ public:
     unique_ptr_128(T* ptr): ptr(ptr) {}
     T* operator->() const { return ptr; }
     T* get() const { return ptr; }
-    T* release() { T* p = ptr; ptr = nullptr; return p; }
+    T* detach() { T* p = ptr; ptr = nullptr; return p; }
 
     unique_ptr_128(const unique_ptr_128&) = delete;
     unique_ptr_128& operator=(const unique_ptr_128&) = delete;
@@ -32,14 +32,14 @@ public:
     ~unique_ptr_128(){ PK_POOL128_DELETE(ptr) }
 
     template<typename U>
-    unique_ptr_128(unique_ptr_128<U>&& other): ptr(other.release()) {}
+    unique_ptr_128(unique_ptr_128<U>&& other): ptr(other.detach()) {}
 
     operator bool() const { return ptr != nullptr; }
 
     template<typename U>
     unique_ptr_128& operator=(unique_ptr_128<U>&& other) {
         PK_POOL128_DELETE(ptr)
-        ptr = other.release();
+        ptr = other.detach();
         return *this;
     }
 
@@ -53,6 +53,11 @@ public:
 typedef unique_ptr_128<Expr> Expr_;
 typedef small_vector<Expr_, 6> Expr_vector;
 
+template<>
+struct TriviallyRelocatable<Expr_>{
+    constexpr static bool value = true;
+};
+
 struct Expr{
     int line = 0;
     virtual ~Expr() = default;

+ 0 - 10
include/pocketpy/vector.h

@@ -190,21 +190,11 @@ namespace pkpy {
     constexpr inline bool is_trivially_relocatable_v =
             TriviallyRelocatable<T>::value;
 
-    template<typename T>
-    struct TriviallyRelocatable<std::unique_ptr<T>>{
-        constexpr static bool value = true;
-    };
-
     template<typename T>
     struct TriviallyRelocatable<std::shared_ptr<T>>{
         constexpr static bool value = true;
     };
 
-    template<typename T>
-    struct TriviallyRelocatable<std::weak_ptr<T>>{
-        constexpr static bool value = true;
-    };
-
     template<typename T>
     struct TriviallyRelocatable<std::vector<T>>{
         constexpr static bool value = true;