dispatcher: enqueue works fine with aggregates now (close #491)

This commit is contained in:
Michele Caini
2020-05-23 00:40:42 +02:00
parent c8f0afb775
commit 7db0f540bd
2 changed files with 6 additions and 2 deletions

View File

@@ -372,7 +372,7 @@ the messages that are still pending are sent to the listeners at once:
```cpp
// emits all the events of the given type at once
dispatcher.update<my_event>();
dispatcher.update<an_event>();
// emits all the events queued so far at once
dispatcher.update();

View File

@@ -66,7 +66,11 @@ class dispatcher {
template<typename... Args>
void enqueue(Args &&... args) {
events.emplace_back(std::forward<Args>(args)...);
if constexpr(std::is_aggregate_v<Event>) {
events.push_back(Event{std::forward<Args>(args)...});
} else {
events.emplace_back(std::forward<Args>(args)...);
}
}
id_type type_id() const ENTT_NOEXCEPT override {