1
0
Эх сурвалжийг харах

any: detect C-style arrays and use delete[] when needed

Michele Caini 5 жил өмнө
parent
commit
505cfdd193
1 өөрчлөгдсөн 5 нэмэгдсэн , 1 устгасан
  1. 5 1
      src/entt/core/any.hpp

+ 5 - 1
src/entt/core/any.hpp

@@ -115,7 +115,11 @@ class any {
                     as<any>(to).instance = from.instance;
                     break;
                 case operation::DTOR:
-                    delete static_cast<const Type *>(from.instance);
+                    if constexpr(std::is_array_v<Type>) {
+                        delete[] static_cast<const Type *>(from.instance);
+                    } else {
+                        delete static_cast<const Type *>(from.instance);
+                    }
                     break;
                 case operation::COMP:
                     return compare<Type>(from.instance, to) ? to : nullptr;