diff --git a/src/entt/core/any.hpp b/src/entt/core/any.hpp index 484e4d462..87cf13b2a 100644 --- a/src/entt/core/any.hpp +++ b/src/entt/core/any.hpp @@ -122,8 +122,9 @@ class basic_any { template void initialize([[maybe_unused]] Args &&...args) { + info = &type_id>>(); + if constexpr(!std::is_void_v) { - info = &type_id>>(); vtable = basic_vtable>>; if constexpr(std::is_lvalue_reference_v) { @@ -160,10 +161,7 @@ public: /*! @brief Default constructor. */ constexpr basic_any() noexcept - : instance{}, - info{&type_id()}, - vtable{}, - mode{policy::owner} {} + : basic_any{std::in_place_type} {} /** * @brief Constructs a wrapper by directly initializing the new object. @@ -173,7 +171,10 @@ public: */ template explicit basic_any(std::in_place_type_t, Args &&...args) - : basic_any{} { + : instance{}, + info{}, + vtable{}, + mode{policy::owner} { initialize(std::forward(args)...); }