-
Notifications
You must be signed in to change notification settings - Fork 659
Description
Is your feature request related to a problem? Please describe.
Somewhat related to a problem, yes. In Java, it is possible to run a Command until a Trigger occurs using myCommand().until(myTrigger())
. This works because Trigger
inherits from BooleanSupplier
. The problem being that this does not work in C++. frc2::Trigger
does not inherit from anything, and Until()
takes a std::function<bool()>
as input.
Describe the solution you'd like
Would be great if either:
- the C++
frc2::Trigger
inherited fromstd::function<bool()>
, or Until()
had the option of taking anfrc2::Trigger
as input.
This would allow MyCommand().Until(MyTrigger())
.
Describe alternatives you've considered
The currently possible alternative is to do MyCommand().Until([]{ return MyTrigger().Get(); });
. While this does work, it gets messy when you have to do it a lot.
Another potential solution is to add some sort of "Convert to function" option in Trigger, like so: MyCommand().Until(MyTrigger().AsFunction());
, but I feel it might as well work the same way as it does in Java.
Additional context
This may also apply to other decorators like .OnlyWhile()
or .Unless()
. But supporting Until()
would be a great start.