|
|
@@ -122,26 +122,27 @@ class basic_any {
|
|
|
|
|
|
template<typename Type, typename... Args>
|
|
|
void initialize([[maybe_unused]] Args &&...args) {
|
|
|
- info = &type_id<std::remove_cv_t<std::remove_reference_t<Type>>>();
|
|
|
+ using basic_type = std::remove_cv_t<std::remove_reference_t<Type>>;
|
|
|
+ info = &type_id<basic_type>();
|
|
|
|
|
|
if constexpr(!std::is_void_v<Type>) {
|
|
|
- vtable = basic_vtable<std::remove_cv_t<std::remove_reference_t<Type>>>;
|
|
|
+ vtable = basic_vtable<basic_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<Type>) {
|
|
|
- if constexpr(sizeof...(Args) != 0u && std::is_aggregate_v<Type>) {
|
|
|
- new(&storage) Type{std::forward<Args>(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 {
|
|
|
- new(&storage) Type(std::forward<Args>(args)...);
|
|
|
+ new(&storage) basic_type(std::forward<Args>(args)...);
|
|
|
}
|
|
|
} else {
|
|
|
- if constexpr(sizeof...(Args) != 0u && std::is_aggregate_v<Type>) {
|
|
|
- instance = new Type{std::forward<Args>(args)...};
|
|
|
+ if constexpr(sizeof...(Args) != 0u && std::is_aggregate_v<basic_type>) {
|
|
|
+ instance = new basic_type{std::forward<Args>(args)...};
|
|
|
} else {
|
|
|
- instance = new Type(std::forward<Args>(args)...);
|
|
|
+ instance = new basic_type(std::forward<Args>(args)...);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -500,7 +501,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<std::conditional_t<std::is_rvalue_reference_v<Type>, std::decay_t<Type>, Type>>, std::forward<Type>(value)};
|
|
|
+ return basic_any<Len, Align>{std::in_place_type<Type>, std::forward<Type>(value)};
|
|
|
}
|
|
|
|
|
|
} // namespace entt
|