From 057a64710c433fd92d8fad7941666fdaa61931bf Mon Sep 17 00:00:00 2001 From: Georg Hagen Date: Fri, 2 Aug 2024 16:26:14 +0200 Subject: [PATCH] automatically convert enum classes in named events to ints --- openVulkanoCpp/Base/Event.hpp | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/openVulkanoCpp/Base/Event.hpp b/openVulkanoCpp/Base/Event.hpp index 5224a70..a547e88 100644 --- a/openVulkanoCpp/Base/Event.hpp +++ b/openVulkanoCpp/Base/Event.hpp @@ -227,12 +227,30 @@ namespace OpenVulkano {} void Notify(Arguments... args) const override + { + NotifyImpl(std::forward(args)...); + } + + void NotifyImpl(Arguments... args) const { if (INamedEventProcessor::HasProcessor()) { std::vector attributes; attributes.reserve(sizeof...(Arguments)); - (attributes.emplace_back(args), ...); + if constexpr (!std::conjunction_v>...>) + { + (attributes.emplace_back(args), ...); + } + else + { + auto fill = [&](auto&& arg) { + if constexpr (std::is_enum_v>) + attributes.emplace_back(static_cast(arg)); + else + attributes.emplace_back(std::forward(arg)); + }; + (fill(std::forward(args)), ...); + } INamedEventProcessor::NotifyAll(m_name, attributes); } }