From 5dbdb1bcb56060dec2b3e2f0284eb4909955058f Mon Sep 17 00:00:00 2001 From: Michele Caini Date: Tue, 6 Apr 2021 09:07:04 +0200 Subject: [PATCH] any: internal support for both aggreagates and non-aggregates (qol enhancement :) --- src/entt/core/any.hpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) 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)...); + } } } }