From 103c703208eded2cc4a7347510cc10be24665b3c Mon Sep 17 00:00:00 2001 From: Deukhoofd Date: Fri, 14 Aug 2020 14:10:13 +0200 Subject: [PATCH] Add cool new c++ 20 constraint to EventHook. Signed-off-by: Deukhoofd --- src/Battling/EventHooks/EventHook.hpp | 4 +++- src/Battling/Models/Battle.hpp | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/Battling/EventHooks/EventHook.hpp b/src/Battling/EventHooks/EventHook.hpp index 5edfb6d..66ea46b 100644 --- a/src/Battling/EventHooks/EventHook.hpp +++ b/src/Battling/EventHooks/EventHook.hpp @@ -7,6 +7,8 @@ #include "../../Library/Exceptions/CreatureException.hpp" #include "Events/EventData.hpp" +template concept Event = std::is_base_of::value; + namespace CreatureLib::Battling { /// The Event Hook class allows users to write consumers for the battle events, for example to write User Interfaces /// for it. @@ -39,7 +41,7 @@ namespace CreatureLib::Battling { size_t GetPosition() const noexcept { return _offset; } size_t GetCapacity() const noexcept { return _capacity; } - template void Trigger(parameters... args) { + template void Trigger(parameters... args) { if (_listeners.size() == 0) return; diff --git a/src/Battling/Models/Battle.hpp b/src/Battling/Models/Battle.hpp index e63c9f8..a51d956 100644 --- a/src/Battling/Models/Battle.hpp +++ b/src/Battling/Models/Battle.hpp @@ -100,7 +100,7 @@ namespace CreatureLib::Battling { void DisplayText(const ArbUt::StringView& text); void RegisterEventListener(EventHook::EventHookFunc listener) { this->_eventHook.RegisterListener(listener); } - template void TriggerEventListener(parameters... args) { + template void TriggerEventListener(parameters... args) { this->_eventHook.Trigger(args...); } };