-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Event::operator bool
#2968
Event::operator bool
#2968
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like this! It's great to remove output parameters without adding any extra ergonomic issues.
Pull Request Test Coverage Report for Build 8934117997Details
💛 - Coveralls |
3da243d
to
47a7350
Compare
Cleaned up the commit history to prepare for merge. No changes made. |
7cb7f96
to
00d69ac
Compare
00d69ac
to
2703630
Compare
Looks like a macos build failed because it took too long to clone? Any way to re-trigger it? |
Nothing you can do, I've rerun the failed job. |
Description
This PR aims to simplify the usage of
Event
when polling events from aRenderWindow
. Instead of having to initialize anEvent
on the stack and pass it by reference topollEvent
/waitEvent
, this PR makes the methods return anEvent
, which can be converted to abool
based on whether its subtype isEmpty
.There was discussion about having
pollEvent
andwaitEvent
returnstd::optional<Event>
, but consideringEvent
already uses subtyping to determine if it contains event data, lettingEvent
be convertible tobool
(based on whether the inner data was of typeEvent::Empty
) sounded like the better option. Plus, we can avoid the clunky->
syntax used for accessing members of anstd::optional
's inner type.Tasks
How to test this PR?
Use an
sf::RenderWindow
while processing events.