diff --git a/src/uvw/emitter.h b/src/uvw/emitter.h index 92bf23f6..56d44704 100644 --- a/src/uvw/emitter.h +++ b/src/uvw/emitter.h @@ -86,10 +86,9 @@ public: using listener_t = std::function; private: - template auto &handler() const UVW_NOEXCEPT { - static_assert((std::is_same_v || ...), "U is not a supported event type for this emitter"); + static_assert(std::is_same_v || (std::is_same_v || ...), "U is not a supported event type for this emitter"); return std::get>(handlers); } @@ -102,7 +101,7 @@ private: protected: template void publish(U event) { - if (auto& listener = handler(); listener) { + if(auto &listener = handler(); listener) { listener(event, *static_cast(this)); } } @@ -139,6 +138,7 @@ public: * @brief Disconnects all listeners. */ void reset() UVW_NOEXCEPT { + reset(); (reset(), ...); } @@ -149,7 +149,7 @@ public: */ template bool has() const UVW_NOEXCEPT { - if constexpr((std::is_same_v || ...)) { + if constexpr(std::is_same_v || (std::is_same_v || ...)) { return static_cast(handler()); } else { return false; diff --git a/test/uvw/emitter.cpp b/test/uvw/emitter.cpp index 408bda86..29d9ec7c 100644 --- a/test/uvw/emitter.cpp +++ b/test/uvw/emitter.cpp @@ -27,7 +27,7 @@ TEST(ErrorEvent, Functionalities) { TEST(Emitter, Functionalities) { TestEmitter emitter{}; - emitter.on([](const uvw::error_event &, TestEmitter &) {}); + emitter.on([](const auto &, auto &) {}); ASSERT_TRUE(emitter.has()); ASSERT_FALSE(emitter.has());