-
Notifications
You must be signed in to change notification settings - Fork 665
Allow .Until(Trigger()) in C++ #8106
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
base: main
Are you sure you want to change the base?
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.
Nice work!
* | ||
* @return A std::function<bool()> representing the condition of this trigger. | ||
*/ | ||
operator std::function<bool()>() const { return m_condition; } |
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.
Nit: I'd move this below Debounce()
(probably under Get()
too), since operator&&
, operator||
, operator!()
, and Debounce()
are all methods that create different Trigger
s, but this defines a conversion into a different type. (In other words, Debounce()
is more similar to the other operators than the conversion operator is.)
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.
Looks good to me, for what it's worth! Since I'm not a full maintainer, you'll still need a full maintainer to approve this PR before it can be merged.
Could the macOS check fail just be due to resources being busy? If so, can someone re-run please? |
wpilibNewCommands/src/main/native/include/frc2/command/button/Trigger.h
Outdated
Show resolved
Hide resolved
Co-authored-by: Joseph Eng <[email protected]>
Fixes #8031
Define operator std::function<bool()>() in Trigger, allowing implicit conversions from Trigger to std::function<bool()>. This is primarily so triggers can be used in command decorators like .Until().