diff --git a/src/entt/core/any.hpp b/src/entt/core/any.hpp index d29eb5b72..28c97f39d 100644 --- a/src/entt/core/any.hpp +++ b/src/entt/core/any.hpp @@ -178,9 +178,17 @@ class basic_any { static_assert(sizeof...(Args) == 1u && (std::is_lvalue_reference_v && ...), "Invalid arguments"); instance = (std::addressof(args), ...); } else if constexpr(in_situ) { - new (&storage) Type{std::forward(args)...}; + if constexpr(std::is_aggregate_v) { + new (&storage) Type{std::forward(args)...}; + } else { + new (&storage) Type(std::forward(args)...); + } } else { - instance = new Type{std::forward(args)...}; + if constexpr(std::is_aggregate_v) { + instance = new Type{std::forward(args)...}; + } else { + instance = new Type(std::forward(args)...); + } } } }