From 0831f055ce85a28fff522174916ea6a53f08a1d3 Mon Sep 17 00:00:00 2001 From: Chris Thrasher Date: Sun, 21 Jul 2024 10:46:09 -0600 Subject: [PATCH] Require that `sf::WindowBase::handleEvents` receives at least one argument --- include/SFML/Window/WindowBase.inl | 2 ++ test/Window/WindowBase.test.cpp | 3 --- 2 files changed, 2 insertions(+), 3 deletions(-) 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&) {});