Browse Source

any: internal changes

skypjack 5 months ago
parent
commit
828ecb57e6
1 changed files with 8 additions and 6 deletions
  1. 8 6
      src/entt/core/any.hpp

+ 8 - 6
src/entt/core/any.hpp

@@ -155,6 +155,12 @@ class basic_any {
           descriptor{other.descriptor},
           descriptor{other.descriptor},
           mode{pol} {}
           mode{pol} {}
 
 
+    void destroy_if_owner() {
+        if(owner()) {
+            vtable(request::destroy, *this, nullptr);
+        }
+    }
+
 public:
 public:
     /*! @brief Size of the internal storage. */
     /*! @brief Size of the internal storage. */
     static constexpr auto length = Len;
     static constexpr auto length = Len;
@@ -231,10 +237,8 @@ public:
 
 
     /*! @brief Frees the internal storage, whatever it means. */
     /*! @brief Frees the internal storage, whatever it means. */
     ~basic_any() {
     ~basic_any() {
-        if(owner()) {
-            vtable(request::destroy, *this, nullptr);
+        destroy_if_owner();
         }
         }
-    }
 
 
     /**
     /**
      * @brief Copy assignment operator.
      * @brief Copy assignment operator.
@@ -436,9 +440,7 @@ public:
 
 
     /*! @brief Destroys contained object */
     /*! @brief Destroys contained object */
     void reset() {
     void reset() {
-        if(owner()) {
-            vtable(request::destroy, *this, nullptr);
-        }
+        destroy_if_owner();
 
 
         instance = nullptr;
         instance = nullptr;
         vtable = nullptr;
         vtable = nullptr;