From 505cfdd1939860a9d548005d997c52e7e9b58c22 Mon Sep 17 00:00:00 2001 From: Michele Caini Date: Wed, 13 Jan 2021 13:30:10 +0100 Subject: [PATCH] any: detect C-style arrays and use delete[] when needed --- src/entt/core/any.hpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/entt/core/any.hpp b/src/entt/core/any.hpp index 653685838..c8feaff64 100644 --- a/src/entt/core/any.hpp +++ b/src/entt/core/any.hpp @@ -115,7 +115,11 @@ class any { as(to).instance = from.instance; break; case operation::DTOR: - delete static_cast(from.instance); + if constexpr(std::is_array_v) { + delete[] static_cast(from.instance); + } else { + delete static_cast(from.instance); + } break; case operation::COMP: return compare(from.instance, to) ? to : nullptr;