mirror of
https://github.com/SFML/SFML.git
synced 2025-01-31 13:45:13 +08:00
More explicit naming for visit and handleEvents types and fix lint comments
This commit is contained in:
parent
37c87ee11e
commit
23afdc2f9e
@ -346,8 +346,8 @@ public:
|
|||||||
/// \return The result of applying the visitor to the event
|
/// \return The result of applying the visitor to the event
|
||||||
///
|
///
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
template <typename T>
|
template <typename Visitor>
|
||||||
decltype(auto) visit(T&& visitor);
|
decltype(auto) visit(Visitor&& visitor);
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief Apply a visitor to the event
|
/// \brief Apply a visitor to the event
|
||||||
@ -357,8 +357,8 @@ public:
|
|||||||
/// \return The result of applying the visitor to the event
|
/// \return The result of applying the visitor to the event
|
||||||
///
|
///
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
template <typename T>
|
template <typename Visitor>
|
||||||
decltype(auto) visit(T&& visitor) const;
|
decltype(auto) visit(Visitor&& visitor) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
|
@ -79,18 +79,18 @@ const TEventSubtype* Event::getIf() const
|
|||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
template <typename T>
|
template <typename Visitor>
|
||||||
decltype(auto) Event::visit(T&& 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>
|
template <typename Visitor>
|
||||||
decltype(auto) Event::visit(T&& visitor) const
|
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
|
} // namespace sf
|
||||||
|
@ -326,8 +326,8 @@ public:
|
|||||||
/// \see `waitEvent`, `pollEvent`
|
/// \see `waitEvent`, `pollEvent`
|
||||||
///
|
///
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
template <typename... Ts>
|
template <typename... Handlers>
|
||||||
void handleEvents(Ts&&... handlers);
|
void handleEvents(Handlers&&... handlers);
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief Get the position of the window
|
/// \brief Get the position of the window
|
||||||
|
@ -57,16 +57,17 @@ struct DelayOverloadResolution
|
|||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
template <typename... Ts>
|
template <typename... Handlers>
|
||||||
void WindowBase::handleEvents(Ts&&... handlers) // NOLINT(cppcoreguidelines-missing-std-forward)
|
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
|
// 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)
|
// 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())
|
while (std::optional event = pollEvent())
|
||||||
event->visit(overloadSet);
|
event->visit(overloadSet);
|
||||||
|
Loading…
Reference in New Issue
Block a user