blueloveTH 2 anni fa
parent
commit
a79d4e0d38
2 ha cambiato i file con 8 aggiunte e 13 eliminazioni
  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) {}
     unique_ptr_128(T* ptr): ptr(ptr) {}
     T* operator->() const { return ptr; }
     T* operator->() const { return ptr; }
     T* get() 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(const unique_ptr_128&) = delete;
     unique_ptr_128& operator=(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) }
     ~unique_ptr_128(){ PK_POOL128_DELETE(ptr) }
 
 
     template<typename U>
     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; }
     operator bool() const { return ptr != nullptr; }
 
 
     template<typename U>
     template<typename U>
     unique_ptr_128& operator=(unique_ptr_128<U>&& other) {
     unique_ptr_128& operator=(unique_ptr_128<U>&& other) {
         PK_POOL128_DELETE(ptr)
         PK_POOL128_DELETE(ptr)
-        ptr = other.release();
+        ptr = other.detach();
         return *this;
         return *this;
     }
     }
 
 
@@ -53,6 +53,11 @@ public:
 typedef unique_ptr_128<Expr> Expr_;
 typedef unique_ptr_128<Expr> Expr_;
 typedef small_vector<Expr_, 6> Expr_vector;
 typedef small_vector<Expr_, 6> Expr_vector;
 
 
+template<>
+struct TriviallyRelocatable<Expr_>{
+    constexpr static bool value = true;
+};
+
 struct Expr{
 struct Expr{
     int line = 0;
     int line = 0;
     virtual ~Expr() = default;
     virtual ~Expr() = default;

+ 0 - 10
include/pocketpy/vector.h

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