added default constructor

This commit is contained in:
Jorijn van der Graaf 2025-11-25 02:07:05 +01:00
commit 7078bcf5ba

View file

@ -1,12 +1,11 @@
/* /*
Crafter®.Event Crafter®.Event
Copyright (C) 2025 Catcrafts® Copyright (C) 2025 Catcrafts®
Catcrafts.net catcrafts.net
This library is free software; you can redistribute it and/or This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either License version 3.0 as published by the Free Software Foundation;
version 3.0 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful, This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
@ -60,6 +59,7 @@ namespace Crafter {
class Event { class Event {
public: public:
std::map<int, std::vector<EventListener<T>*>> listeners; std::map<int, std::vector<EventListener<T>*>> listeners;
Event() = default;
Event(Event&& other) : listeners(std::move(other.listeners)) { Event(Event&& other) : listeners(std::move(other.listeners)) {
for (const auto& listenerSlice : listeners) { for (const auto& listenerSlice : listeners) {
for (const auto& listener : listenerSlice.second) { for (const auto& listener : listenerSlice.second) {
@ -128,6 +128,7 @@ namespace Crafter {
class Event<void> { class Event<void> {
public: public:
std::map<int, std::vector<EventListener<void>*>> listeners; std::map<int, std::vector<EventListener<void>*>> listeners;
Event() = default;
Event(Event&& other) : listeners(std::move(other.listeners)) { Event(Event&& other) : listeners(std::move(other.listeners)) {
for (const auto& listenerSlice : listeners) { for (const auto& listenerSlice : listeners) {
for (const auto& listener : listenerSlice.second) { for (const auto& listener : listenerSlice.second) {