From 23afdc2f9e1c6d9eeee6d28937c536f0cad5d4f8 Mon Sep 17 00:00:00 2001 From: kimci86 Date: Sat, 25 Jan 2025 23:37:48 +0100 Subject: [PATCH] More explicit naming for visit and handleEvents types and fix lint comments --- include/SFML/Window/Event.hpp | 8 ++++---- include/SFML/Window/Event.inl | 12 ++++++------ include/SFML/Window/WindowBase.hpp | 4 ++-- include/SFML/Window/WindowBase.inl | 11 ++++++----- 4 files changed, 18 insertions(+), 17 deletions(-) diff --git a/include/SFML/Window/Event.hpp b/include/SFML/Window/Event.hpp index df2972b6a..9c84a09d1 100644 --- a/include/SFML/Window/Event.hpp +++ b/include/SFML/Window/Event.hpp @@ -346,8 +346,8 @@ public: /// \return The result of applying the visitor to the event /// //////////////////////////////////////////////////////////// - template - decltype(auto) visit(T&& visitor); + template + decltype(auto) visit(Visitor&& visitor); //////////////////////////////////////////////////////////// /// \brief Apply a visitor to the event @@ -357,8 +357,8 @@ public: /// \return The result of applying the visitor to the event /// //////////////////////////////////////////////////////////// - template - decltype(auto) visit(T&& visitor) const; + template + decltype(auto) visit(Visitor&& visitor) const; private: //////////////////////////////////////////////////////////// diff --git a/include/SFML/Window/Event.inl b/include/SFML/Window/Event.inl index daabd2fd3..5cd94ed0b 100644 --- a/include/SFML/Window/Event.inl +++ b/include/SFML/Window/Event.inl @@ -79,18 +79,18 @@ const TEventSubtype* Event::getIf() const //////////////////////////////////////////////////////////// -template -decltype(auto) Event::visit(T&& visitor) +template +decltype(auto) Event::visit(Visitor&& visitor) { - return std::visit(std::forward(visitor), m_data); + return std::visit(std::forward(visitor), m_data); } //////////////////////////////////////////////////////////// -template -decltype(auto) Event::visit(T&& visitor) const +template +decltype(auto) Event::visit(Visitor&& visitor) const { - return std::visit(std::forward(visitor), m_data); + return std::visit(std::forward(visitor), m_data); } } // namespace sf diff --git a/include/SFML/Window/WindowBase.hpp b/include/SFML/Window/WindowBase.hpp index def09882b..6baf0e39c 100644 --- a/include/SFML/Window/WindowBase.hpp +++ b/include/SFML/Window/WindowBase.hpp @@ -326,8 +326,8 @@ public: /// \see `waitEvent`, `pollEvent` /// //////////////////////////////////////////////////////////// - template - void handleEvents(Ts&&... handlers); + template + void handleEvents(Handlers&&... handlers); //////////////////////////////////////////////////////////// /// \brief Get the position of the window diff --git a/include/SFML/Window/WindowBase.inl b/include/SFML/Window/WindowBase.inl index 2c5c89c7b..730b9435a 100644 --- a/include/SFML/Window/WindowBase.inl +++ b/include/SFML/Window/WindowBase.inl @@ -57,16 +57,17 @@ struct DelayOverloadResolution //////////////////////////////////////////////////////////// -template -void WindowBase::handleEvents(Ts&&... handlers) // NOLINT(cppcoreguidelines-missing-std-forward) +template +void WindowBase::handleEvents(Handlers&&... handlers) { - static_assert(sizeof...(Ts) > 0, "Must provide at least one handler"); + static_assert(sizeof...(Handlers) > 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 + // complains about it even though the code would become incorrect // NOLINTNEXTLINE(misc-const-correctness) - priv::OverloadSet overloadSet{std::forward(handlers)..., [](const priv::DelayOverloadResolution&) { /* ignore */ }}; + priv::OverloadSet overloadSet{std::forward(handlers)..., + [](const priv::DelayOverloadResolution&) { /* ignore */ }}; while (std::optional event = pollEvent()) event->visit(overloadSet);