any/meta: work around the bugs of toolset v141 to also make it happy if possible

This commit is contained in:
Michele Caini
2022-10-08 19:51:49 +02:00
parent 4b10981d75
commit 50349dc2af
2 changed files with 11 additions and 12 deletions

View File

@@ -122,27 +122,26 @@ class basic_any {
template<typename Type, typename... Args>
void initialize([[maybe_unused]] Args &&...args) {
using basic_type = std::remove_cv_t<std::remove_reference_t<Type>>;
info = &type_id<basic_type>();
info = &type_id<std::remove_cv_t<std::remove_reference_t<Type>>>();
if constexpr(!std::is_void_v<Type>) {
vtable = basic_vtable<basic_type>;
vtable = basic_vtable<std::remove_cv_t<std::remove_reference_t<Type>>>;
if constexpr(std::is_lvalue_reference_v<Type>) {
static_assert(sizeof...(Args) == 1u && (std::is_lvalue_reference_v<Args> && ...), "Invalid arguments");
mode = std::is_const_v<std::remove_reference_t<Type>> ? policy::cref : policy::ref;
instance = (std::addressof(args), ...);
} else if constexpr(in_situ<basic_type>) {
if constexpr(sizeof...(Args) != 0u && std::is_aggregate_v<basic_type>) {
new(&storage) basic_type{std::forward<Args>(args)...};
} else if constexpr(in_situ<std::remove_const_t<std::remove_reference_t<Type>>>) {
if constexpr(sizeof...(Args) != 0u && std::is_aggregate_v<std::remove_cv_t<std::remove_reference_t<Type>>>) {
new(&storage) std::remove_cv_t<std::remove_reference_t<Type>>{std::forward<Args>(args)...};
} else {
new(&storage) basic_type(std::forward<Args>(args)...);
new(&storage) std::remove_cv_t<std::remove_reference_t<Type>>(std::forward<Args>(args)...);
}
} else {
if constexpr(sizeof...(Args) != 0u && std::is_aggregate_v<basic_type>) {
instance = new basic_type{std::forward<Args>(args)...};
if constexpr(sizeof...(Args) != 0u && std::is_aggregate_v<std::remove_cv_t<std::remove_reference_t<Type>>>) {
instance = new std::remove_cv_t<std::remove_reference_t<Type>>{std::forward<Args>(args)...};
} else {
instance = new basic_type(std::forward<Args>(args)...);
instance = new std::remove_cv_t<std::remove_reference_t<Type>>(std::forward<Args>(args)...);
}
}
}
@@ -501,7 +500,7 @@ basic_any<Len, Align> make_any(Args &&...args) {
*/
template<std::size_t Len = basic_any<>::length, std::size_t Align = basic_any<Len>::alignment, typename Type>
basic_any<Len, Align> forward_as_any(Type &&value) {
return basic_any<Len, Align>{std::in_place_type<Type>, std::forward<Type>(value)};
return basic_any<Len, Align>{std::in_place_type<Type &&>, std::forward<Type>(value)};
}
} // namespace entt

View File

@@ -564,7 +564,7 @@ meta_any make_meta(Args &&...args) {
*/
template<typename Type>
meta_any forward_as_meta(Type &&value) {
return meta_any{std::in_place_type<Type>, std::forward<Type>(value)};
return meta_any{std::in_place_type<Type &&>, std::forward<Type>(value)};
}
/**