From 133f6a0a289eb8da7b4ae2ca788e15fd4625aaf5 Mon Sep 17 00:00:00 2001 From: Michele Caini Date: Thu, 20 Jun 2024 09:26:39 +0200 Subject: [PATCH] any: get around an issue with latest MSVC and C++20 --- src/entt/core/any.hpp | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/src/entt/core/any.hpp b/src/entt/core/any.hpp index 7b7858c0d..93ffba3e6 100644 --- a/src/entt/core/any.hpp +++ b/src/entt/core/any.hpp @@ -114,26 +114,29 @@ class basic_any { template void initialize([[maybe_unused]] Args &&...args) { - info = &type_id>>(); + using plain_type = std::remove_cv_t>; + info = &type_id(); if constexpr(!std::is_void_v) { - vtable = basic_vtable>>; + vtable = basic_vtable; if constexpr(std::is_lvalue_reference_v) { static_assert((std::is_lvalue_reference_v && ...) && (sizeof...(Args) == 1u), "Invalid arguments"); mode = std::is_const_v> ? any_policy::cref : any_policy::ref; instance = (std::addressof(args), ...); - } else if constexpr(in_situ>>) { - if constexpr(std::is_aggregate_v>> && (sizeof...(Args) != 0u || !std::is_default_constructible_v>>)) { - ::new(storage.data()) std::remove_cv_t>{std::forward(args)...}; + } else if constexpr(in_situ) { + if constexpr(std::is_aggregate_v && (sizeof...(Args) != 0u || !std::is_default_constructible_v)) { + ::new(storage.data()) plain_type{std::forward(args)...}; } else { - ::new(storage.data()) std::remove_cv_t>(std::forward(args)...); + ::new(storage.data()) plain_type(std::forward(args)...); } } else { - if constexpr(std::is_aggregate_v>> && (sizeof...(Args) != 0u || !std::is_default_constructible_v>>)) { - instance = new std::remove_cv_t>{std::forward(args)...}; + if constexpr(std::is_aggregate_v && (sizeof...(Args) != 0u || !std::is_default_constructible_v)) { + instance = new plain_type{std::forward(args)...}; + } else if constexpr(std::is_array_v) { + instance = new plain_type[std::extent_v](std::forward(args)...); } else { - instance = new std::remove_cv_t>(std::forward(args)...); + instance = new plain_type(std::forward(args)...); } } }