[commands] C++ CommandPtr: Prevent null initialization (#5991)

This commit is contained in:
Starlight220
2023-12-03 02:45:04 +02:00
committed by GitHub
parent 96914143ba
commit 5172ab8fd0
3 changed files with 12 additions and 2 deletions

View File

@@ -27,8 +27,7 @@ namespace frc2 {
*/
class CommandPtr final {
public:
explicit CommandPtr(std::unique_ptr<Command>&& command)
: m_ptr(std::move(command)) {}
explicit CommandPtr(std::unique_ptr<Command>&& command);
template <std::derived_from<Command> T>
// NOLINTNEXTLINE(bugprone-forwarding-reference-overload)
@@ -39,6 +38,8 @@ class CommandPtr final {
CommandPtr(CommandPtr&&) = default;
CommandPtr& operator=(CommandPtr&&) = default;
explicit CommandPtr(std::nullptr_t) = delete;
/**
* Decorates this command to run repeatedly, restarting it when it ends, until
* this command is interrupted. The decorated command can still be canceled.