any: use actual constructors to be more like std::any

This commit is contained in:
Michele Caini
2021-01-15 17:24:10 +01:00
parent 0ec755fccf
commit ba098e1199
3 changed files with 6 additions and 2 deletions

View File

@@ -167,9 +167,9 @@ public:
ENTT_ASSERT(((args != nullptr) && ...));
instance = (args, ...);
} else if constexpr(in_situ<Type>) {
new (&storage) Type{std::forward<Args>(args)...};
new (&storage) Type(std::forward<Args>(args)...);
} else {
instance = new Type{std::forward<Args>(args)...};
instance = new Type(std::forward<Args>(args)...);
}
}
}

View File

@@ -31,6 +31,8 @@ struct Deduced: entt::type_list<> {
};
struct impl {
impl() = default;
impl(int v): value{v} {}
void incr() { ++value; }
void set(int v) { value = v; }
int get() const { return value; }

View File

@@ -37,6 +37,8 @@ struct Defined: entt::type_list<
};
struct impl {
impl() = default;
impl(int v): value{v} {}
void incr() { ++value; }
void set(int v) { value = v; }
int get() const { return value; }