automatically convert enum classes in named events to ints
This commit is contained in:
@@ -227,12 +227,30 @@ namespace OpenVulkano
|
|||||||
{}
|
{}
|
||||||
|
|
||||||
void Notify(Arguments... args) const override
|
void Notify(Arguments... args) const override
|
||||||
|
{
|
||||||
|
NotifyImpl(std::forward<Arguments>(args)...);
|
||||||
|
}
|
||||||
|
|
||||||
|
void NotifyImpl(Arguments... args) const
|
||||||
{
|
{
|
||||||
if (INamedEventProcessor::HasProcessor())
|
if (INamedEventProcessor::HasProcessor())
|
||||||
{
|
{
|
||||||
std::vector<INamedEventProcessor::Parameters> attributes;
|
std::vector<INamedEventProcessor::Parameters> attributes;
|
||||||
attributes.reserve(sizeof...(Arguments));
|
attributes.reserve(sizeof...(Arguments));
|
||||||
(attributes.emplace_back(args), ...);
|
if constexpr (!std::conjunction_v<std::is_enum<std::remove_reference_t<Arguments>>...>)
|
||||||
|
{
|
||||||
|
(attributes.emplace_back(args), ...);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
auto fill = [&](auto&& arg) {
|
||||||
|
if constexpr (std::is_enum_v<std::remove_reference_t<decltype(arg)>>)
|
||||||
|
attributes.emplace_back(static_cast<int>(arg));
|
||||||
|
else
|
||||||
|
attributes.emplace_back(std::forward<decltype(arg)>(arg));
|
||||||
|
};
|
||||||
|
(fill(std::forward<Arguments>(args)), ...);
|
||||||
|
}
|
||||||
INamedEventProcessor::NotifyAll(m_name, attributes);
|
INamedEventProcessor::NotifyAll(m_name, attributes);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user