More explicit naming for visit and handleEvents types and fix lint comments

This commit is contained in:
kimci86 2025-01-25 23:37:48 +01:00 committed by Chris Thrasher
parent 37c87ee11e
commit 23afdc2f9e
4 changed files with 18 additions and 17 deletions

View File

@ -346,8 +346,8 @@ public:
/// \return The result of applying the visitor to the event
///
////////////////////////////////////////////////////////////
template <typename T>
decltype(auto) visit(T&& visitor);
template <typename Visitor>
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 <typename T>
decltype(auto) visit(T&& visitor) const;
template <typename Visitor>
decltype(auto) visit(Visitor&& visitor) const;
private:
////////////////////////////////////////////////////////////

View File

@ -79,18 +79,18 @@ const TEventSubtype* Event::getIf() const
////////////////////////////////////////////////////////////
template <typename T>
decltype(auto) Event::visit(T&& visitor)
template <typename Visitor>
decltype(auto) Event::visit(Visitor&& visitor)
{
return std::visit(std::forward<T>(visitor), m_data);
return std::visit(std::forward<Visitor>(visitor), m_data);
}
////////////////////////////////////////////////////////////
template <typename T>
decltype(auto) Event::visit(T&& visitor) const
template <typename Visitor>
decltype(auto) Event::visit(Visitor&& visitor) const
{
return std::visit(std::forward<T>(visitor), m_data);
return std::visit(std::forward<Visitor>(visitor), m_data);
}
} // namespace sf

View File

@ -326,8 +326,8 @@ public:
/// \see `waitEvent`, `pollEvent`
///
////////////////////////////////////////////////////////////
template <typename... Ts>
void handleEvents(Ts&&... handlers);
template <typename... Handlers>
void handleEvents(Handlers&&... handlers);
////////////////////////////////////////////////////////////
/// \brief Get the position of the window

View File

@ -57,16 +57,17 @@ struct DelayOverloadResolution
////////////////////////////////////////////////////////////
template <typename... Ts>
void WindowBase::handleEvents(Ts&&... handlers) // NOLINT(cppcoreguidelines-missing-std-forward)
template <typename... Handlers>
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<Ts>(handlers)..., [](const priv::DelayOverloadResolution&) { /* ignore */ }};
priv::OverloadSet overloadSet{std::forward<Handlers>(handlers)...,
[](const priv::DelayOverloadResolution&) { /* ignore */ }};
while (std::optional event = pollEvent())
event->visit(overloadSet);