Require that sf::WindowBase::handleEvents receives at least one argument

This commit is contained in:
Chris Thrasher 2024-07-21 10:46:09 -06:00
parent c8c8673259
commit 0831f055ce
2 changed files with 2 additions and 3 deletions

View File

@ -57,6 +57,8 @@ struct DelayOverloadResolution
template <typename... Ts> template <typename... Ts>
void WindowBase::handleEvents(Ts&&... handlers) // NOLINT(cppcoreguidelines-missing-std-forward) 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 // Disable misc-const-correctness for this line since clang-tidy
// complains about it even though the code would become uncompilable // complains about it even though the code would become uncompilable

View File

@ -203,9 +203,6 @@ TEST_CASE("[Window] sf::WindowBase", runDisplayTests())
{ {
sf::WindowBase windowBase(sf::VideoMode({360, 240}), "WindowBase Tests"); 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 // Should compile if user provides only a specific handler
windowBase.handleEvents([](const sf::Event::Closed&) {}); windowBase.handleEvents([](const sf::Event::Closed&) {});