Skip to content

Conversation

Liam-Stow
Copy link

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().

@Liam-Stow Liam-Stow requested a review from a team as a code owner July 21, 2025 09:06
@github-actions github-actions bot added the component: command-based WPILib Command Based Library label Jul 21, 2025
Copy link
Contributor

@KangarooKoala KangarooKoala left a 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; }
Copy link
Contributor

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 Triggers, 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.)

Copy link
Contributor

@KangarooKoala KangarooKoala left a 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.

@Liam-Stow
Copy link
Author

Could the macOS check fail just be due to resources being busy? If so, can someone re-run please?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: command-based WPILib Command Based Library
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow .Until(Trigger()) in C++
2 participants