[commands] Mark CommandPtr class as [[nodiscard]] (#7803)

This has the same effect but makes it so any user code returning CommandPtr can't discard a returned command.

Signed-off-by: Eric Ward <ezeward4@gmail.com>
This commit is contained in:
Eric
2025-05-03 23:44:55 -04:00
committed by GitHub
parent 02de5f710e
commit 17cae787e7
11 changed files with 5 additions and 84 deletions

View File

@@ -82,7 +82,6 @@ class DriveSubsystem : public frc2::SubsystemBase {
* @param distance The distance to drive forward.
* @return A command.
*/
[[nodiscard]]
frc2::CommandPtr ProfiledDriveDistance(units::meter_t distance);
/**
@@ -92,7 +91,6 @@ class DriveSubsystem : public frc2::SubsystemBase {
* @param distance The distance to drive forward.
* @return A command.
*/
[[nodiscard]]
frc2::CommandPtr DynamicProfiledDriveDistance(units::meter_t distance);
private:

View File

@@ -28,7 +28,6 @@ class Drive : public frc2::SubsystemBase {
* @param fwd the commanded forward movement
* @param rot the commanded rotation
*/
[[nodiscard]]
frc2::CommandPtr ArcadeDriveCommand(std::function<double()> fwd,
std::function<double()> rot);
@@ -39,7 +38,6 @@ class Drive : public frc2::SubsystemBase {
* @param distance The distance to drive forward in meters
* @param speed The fraction of max speed at which to drive
*/
[[nodiscard]]
frc2::CommandPtr DriveDistanceCommand(units::meter_t distance, double speed);
/**
@@ -48,7 +46,6 @@ class Drive : public frc2::SubsystemBase {
*
* @param angle The angle to turn to
*/
[[nodiscard]]
frc2::CommandPtr TurnToAngleCommand(units::degree_t angle);
private:

View File

@@ -19,11 +19,9 @@ class Intake : public frc2::SubsystemBase {
/** Returns a command that deploys the intake, and then runs the intake motor
* indefinitely. */
[[nodiscard]]
frc2::CommandPtr IntakeCommand();
/** Returns a command that turns off and retracts the intake. */
[[nodiscard]]
frc2::CommandPtr RetractCommand();
private:

View File

@@ -17,7 +17,6 @@ class Pneumatics : frc2::SubsystemBase {
public:
Pneumatics();
/** Returns a command that disables the compressor indefinitely. */
[[nodiscard]]
frc2::CommandPtr DisableCompressorCommand();
/**

View File

@@ -28,7 +28,6 @@ class Shooter : public frc2::SubsystemBase {
*
* @param setpointRotationsPerSecond The desired shooter velocity
*/
[[nodiscard]]
frc2::CommandPtr ShootCommand(units::turns_per_second_t setpoint);
private:

View File

@@ -16,7 +16,6 @@ class Storage : frc2::SubsystemBase {
public:
Storage();
/** Returns a command that runs the storage motor indefinitely. */
[[nodiscard]]
frc2::CommandPtr RunCommand();
/** Whether the ball storage is full. */