mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-20 00:51:42 +00:00
[commands] Add finallyDo with zero-arg lambda (#5862)
This commit is contained in:
@@ -318,6 +318,18 @@ class Command : public wpi::Sendable, public wpi::SendableHelper<Command> {
|
||||
[[nodiscard]]
|
||||
CommandPtr FinallyDo(std::function<void(bool)> end) &&;
|
||||
|
||||
/**
|
||||
* Decorates this command with a lambda to call on interrupt or end, following
|
||||
* the command's inherent Command::End(bool) method. The provided lambda will
|
||||
* run identically in both interrupt and end cases.
|
||||
*
|
||||
* @param end a lambda to run when the command ends, whether or not it was
|
||||
* interrupted.
|
||||
* @return the decorated command
|
||||
*/
|
||||
[[nodiscard]]
|
||||
CommandPtr FinallyDo(std::function<void()> end) &&;
|
||||
|
||||
/**
|
||||
* Decorates this command with a lambda to call on interrupt, following the
|
||||
* command's inherent Command::End(bool) method.
|
||||
|
||||
@@ -223,6 +223,18 @@ class CommandPtr final {
|
||||
[[nodiscard]]
|
||||
CommandPtr FinallyDo(std::function<void(bool)> end) &&;
|
||||
|
||||
/**
|
||||
* Decorates this command with a lambda to call on interrupt or end, following
|
||||
* the command's inherent Command::End(bool) method. The provided lambda will
|
||||
* run identically in both interrupt and end cases.
|
||||
*
|
||||
* @param end a lambda to run when the command ends, whether or not it was
|
||||
* interrupted.
|
||||
* @return the decorated command
|
||||
*/
|
||||
[[nodiscard]]
|
||||
CommandPtr FinallyDo(std::function<void()> end) &&;
|
||||
|
||||
/**
|
||||
* Decorates this command with a lambda to call on interrupt, following the
|
||||
* command's inherent Command::End(bool) method.
|
||||
|
||||
Reference in New Issue
Block a user