diff --git a/include/SFML/Window/WindowBase.inl b/include/SFML/Window/WindowBase.inl index 594692ef7..b1764892a 100644 --- a/include/SFML/Window/WindowBase.inl +++ b/include/SFML/Window/WindowBase.inl @@ -57,6 +57,8 @@ struct DelayOverloadResolution template void WindowBase::handleEvents(Ts&&... handlers) // NOLINT(cppcoreguidelines-missing-std-forward) { + static_assert(sizeof...(Ts) > 0, "Must provide at least one handler"); + // Disable misc-const-correctness for this line since clang-tidy // complains about it even though the code would become uncompilable diff --git a/test/Window/WindowBase.test.cpp b/test/Window/WindowBase.test.cpp index 6bfccba6f..d9dcfb3e3 100644 --- a/test/Window/WindowBase.test.cpp +++ b/test/Window/WindowBase.test.cpp @@ -203,9 +203,6 @@ TEST_CASE("[Window] sf::WindowBase", runDisplayTests()) { sf::WindowBase windowBase(sf::VideoMode({360, 240}), "WindowBase Tests"); - // Should compile if user provides nothing - windowBase.handleEvents(); - // Should compile if user provides only a specific handler windowBase.handleEvents([](const sf::Event::Closed&) {});