Upgrade to C++20 (#4239)

* Use explicit this capture required by C++20
* Use C++20 span
* Replace wpi::numbers with std::numbers
* Fix C++20 clang-tidy warning false positive in fmt
* Remove ciso646 include since C++20 removed that header
* Fix global-buffer-overflow asan warnings in ntcore tests
* Add DIOSetProxy constructor to HAL

* Upgrade MSVC compiler to 2022
* Bump native-utils to 2023.2.7 (changes to std=c++20)

Co-authored-by: Peter Johnson <johnson.peter@gmail.com>
This commit is contained in:
Tyler Veness
2022-10-15 16:33:14 -07:00
committed by GitHub
parent 396143004c
commit fbdc810887
355 changed files with 1659 additions and 2918 deletions

View File

@@ -68,7 +68,7 @@ CommandPtr Command::BeforeStarting(
}
CommandPtr Command::BeforeStarting(
std::function<void()> toRun, wpi::span<Subsystem* const> requirements) && {
std::function<void()> toRun, std::span<Subsystem* const> requirements) && {
return CommandPtr(std::move(*this).TransferOwnership())
.BeforeStarting(std::move(toRun), requirements);
}
@@ -80,7 +80,7 @@ CommandPtr Command::AndThen(std::function<void()> toRun,
}
CommandPtr Command::AndThen(std::function<void()> toRun,
wpi::span<Subsystem* const> requirements) && {
std::span<Subsystem* const> requirements) && {
return CommandPtr(std::move(*this).TransferOwnership())
.AndThen(std::move(toRun), requirements);
}

View File

@@ -18,7 +18,7 @@ void CommandBase::AddRequirements(
m_requirements.insert(requirements.begin(), requirements.end());
}
void CommandBase::AddRequirements(wpi::span<Subsystem* const> requirements) {
void CommandBase::AddRequirements(std::span<Subsystem* const> requirements) {
m_requirements.insert(requirements.begin(), requirements.end());
}

View File

@@ -20,7 +20,7 @@ bool CommandGroupBase::RequireUngrouped(const Command* command) {
}
bool CommandGroupBase::RequireUngrouped(
wpi::span<const std::unique_ptr<Command>> commands) {
std::span<const std::unique_ptr<Command>> commands) {
bool allUngrouped = true;
for (auto&& command : commands) {
allUngrouped &= !command.get()->IsGrouped();

View File

@@ -79,7 +79,7 @@ CommandPtr CommandPtr::WithInterruptBehavior(
}
CommandPtr CommandPtr::AndThen(std::function<void()> toRun,
wpi::span<Subsystem* const> requirements) && {
std::span<Subsystem* const> requirements) && {
return std::move(*this).AndThen(CommandPtr(
std::make_unique<InstantCommand>(std::move(toRun), requirements)));
}
@@ -100,7 +100,7 @@ CommandPtr CommandPtr::AndThen(CommandPtr&& next) && {
}
CommandPtr CommandPtr::BeforeStarting(
std::function<void()> toRun, wpi::span<Subsystem* const> requirements) && {
std::function<void()> toRun, std::span<Subsystem* const> requirements) && {
return std::move(*this).BeforeStarting(CommandPtr(
std::make_unique<InstantCommand>(std::move(toRun), requirements)));
}

View File

@@ -163,7 +163,7 @@ void CommandScheduler::Schedule(Command* command) {
}
}
void CommandScheduler::Schedule(wpi::span<Command* const> commands) {
void CommandScheduler::Schedule(std::span<Command* const> commands) {
for (auto command : commands) {
Schedule(command);
}
@@ -276,7 +276,7 @@ void CommandScheduler::RegisterSubsystem(
}
void CommandScheduler::RegisterSubsystem(
wpi::span<Subsystem* const> subsystems) {
std::span<Subsystem* const> subsystems) {
for (auto* subsystem : subsystems) {
RegisterSubsystem(subsystem);
}
@@ -290,7 +290,7 @@ void CommandScheduler::UnregisterSubsystem(
}
void CommandScheduler::UnregisterSubsystem(
wpi::span<Subsystem* const> subsystems) {
std::span<Subsystem* const> subsystems) {
for (auto* subsystem : subsystems) {
UnregisterSubsystem(subsystem);
}
@@ -336,7 +336,7 @@ void CommandScheduler::Cancel(const CommandPtr& command) {
Cancel(command.get());
}
void CommandScheduler::Cancel(wpi::span<Command* const> commands) {
void CommandScheduler::Cancel(std::span<Command* const> commands) {
for (auto command : commands) {
Cancel(command);
}
@@ -357,7 +357,7 @@ void CommandScheduler::CancelAll() {
}
bool CommandScheduler::IsScheduled(
wpi::span<const Command* const> commands) const {
std::span<const Command* const> commands) const {
for (auto command : commands) {
if (!IsScheduled(command)) {
return false;

View File

@@ -21,7 +21,7 @@ FunctionalCommand::FunctionalCommand(std::function<void()> onInit,
std::function<void()> onExecute,
std::function<void(bool)> onEnd,
std::function<bool()> isFinished,
wpi::span<Subsystem* const> requirements)
std::span<Subsystem* const> requirements)
: m_onInit{std::move(onInit)},
m_onExecute{std::move(onExecute)},
m_onEnd{std::move(onEnd)},

View File

@@ -13,7 +13,7 @@ InstantCommand::InstantCommand(std::function<void()> toRun,
requirements) {}
InstantCommand::InstantCommand(std::function<void()> toRun,
wpi::span<Subsystem* const> requirements)
std::span<Subsystem* const> requirements)
: CommandHelper(
std::move(toRun), [] {}, [](bool interrupted) {}, [] { return true; },
requirements) {}

View File

@@ -98,7 +98,7 @@ MecanumControllerCommand::MecanumControllerCommand(
std::function<void(units::volt_t, units::volt_t, units::volt_t,
units::volt_t)>
output,
wpi::span<Subsystem* const> requirements)
std::span<Subsystem* const> requirements)
: m_trajectory(std::move(trajectory)),
m_pose(std::move(pose)),
m_feedforward(feedforward),
@@ -135,7 +135,7 @@ MecanumControllerCommand::MecanumControllerCommand(
std::function<void(units::volt_t, units::volt_t, units::volt_t,
units::volt_t)>
output,
wpi::span<Subsystem* const> requirements)
std::span<Subsystem* const> requirements)
: m_trajectory(std::move(trajectory)),
m_pose(std::move(pose)),
m_feedforward(feedforward),
@@ -208,7 +208,7 @@ MecanumControllerCommand::MecanumControllerCommand(
std::function<void(units::meters_per_second_t, units::meters_per_second_t,
units::meters_per_second_t, units::meters_per_second_t)>
output,
wpi::span<Subsystem* const> requirements)
std::span<Subsystem* const> requirements)
: m_trajectory(std::move(trajectory)),
m_pose(std::move(pose)),
m_kinematics(kinematics),
@@ -229,7 +229,7 @@ MecanumControllerCommand::MecanumControllerCommand(
std::function<void(units::meters_per_second_t, units::meters_per_second_t,
units::meters_per_second_t, units::meters_per_second_t)>
output,
wpi::span<Subsystem* const> requirements)
std::span<Subsystem* const> requirements)
: m_trajectory(std::move(trajectory)),
m_pose(std::move(pose)),
m_kinematics(kinematics),

View File

@@ -15,7 +15,7 @@ NotifierCommand::NotifierCommand(std::function<void()> toRun,
NotifierCommand::NotifierCommand(std::function<void()> toRun,
units::second_t period,
wpi::span<Subsystem* const> requirements)
std::span<Subsystem* const> requirements)
: m_toRun(toRun), m_notifier{std::move(toRun)}, m_period{period} {
AddRequirements(requirements);
}

View File

@@ -24,7 +24,7 @@ PIDCommand::PIDCommand(PIDController controller,
std::function<double()> measurementSource,
std::function<double()> setpointSource,
std::function<void(double)> useOutput,
wpi::span<Subsystem* const> requirements)
std::span<Subsystem* const> requirements)
: m_controller{std::move(controller)},
m_measurement{std::move(measurementSource)},
m_setpoint{std::move(setpointSource)},
@@ -43,7 +43,7 @@ PIDCommand::PIDCommand(PIDController controller,
PIDCommand::PIDCommand(PIDController controller,
std::function<double()> measurementSource,
double setpoint, std::function<void(double)> useOutput,
wpi::span<Subsystem* const> requirements)
std::span<Subsystem* const> requirements)
: PIDCommand(
controller, measurementSource, [setpoint] { return setpoint; },
useOutput, requirements) {}

View File

@@ -7,7 +7,7 @@
using namespace frc2;
ProxyScheduleCommand::ProxyScheduleCommand(
wpi::span<Command* const> toSchedule) {
std::span<Command* const> toSchedule) {
SetInsert(m_toSchedule, toSchedule);
}

View File

@@ -38,7 +38,7 @@ RamseteCommand::RamseteCommand(
std::function<frc::DifferentialDriveWheelSpeeds()> wheelSpeeds,
frc2::PIDController leftController, frc2::PIDController rightController,
std::function<void(units::volt_t, units::volt_t)> output,
wpi::span<Subsystem* const> requirements)
std::span<Subsystem* const> requirements)
: m_trajectory(std::move(trajectory)),
m_pose(std::move(pose)),
m_controller(controller),
@@ -74,7 +74,7 @@ RamseteCommand::RamseteCommand(
frc::DifferentialDriveKinematics kinematics,
std::function<void(units::meters_per_second_t, units::meters_per_second_t)>
output,
wpi::span<Subsystem* const> requirements)
std::span<Subsystem* const> requirements)
: m_trajectory(std::move(trajectory)),
m_pose(std::move(pose)),
m_controller(controller),

View File

@@ -12,6 +12,6 @@ RunCommand::RunCommand(std::function<void()> toRun,
[] { return false; }, requirements) {}
RunCommand::RunCommand(std::function<void()> toRun,
wpi::span<Subsystem* const> requirements)
std::span<Subsystem* const> requirements)
: CommandHelper([] {}, std::move(toRun), [](bool interrupted) {},
[] { return false; }, requirements) {}

View File

@@ -6,7 +6,7 @@
using namespace frc2;
ScheduleCommand::ScheduleCommand(wpi::span<Command* const> toSchedule) {
ScheduleCommand::ScheduleCommand(std::span<Command* const> toSchedule) {
SetInsert(m_toSchedule, toSchedule);
}

View File

@@ -16,7 +16,7 @@ StartEndCommand::StartEndCommand(std::function<void()> onInit,
StartEndCommand::StartEndCommand(std::function<void()> onInit,
std::function<void()> onEnd,
wpi::span<Subsystem* const> requirements)
std::span<Subsystem* const> requirements)
: CommandHelper(
std::move(onInit), [] {},
[onEnd = std::move(onEnd)](bool interrupted) { onEnd(); },

View File

@@ -25,7 +25,7 @@ Button Button::WhenPressed(std::function<void()> toRun,
}
Button Button::WhenPressed(std::function<void()> toRun,
wpi::span<Subsystem* const> requirements) {
std::span<Subsystem* const> requirements) {
WhenActive(std::move(toRun), requirements);
return *this;
}
@@ -47,7 +47,7 @@ Button Button::WhileHeld(std::function<void()> toRun,
}
Button Button::WhileHeld(std::function<void()> toRun,
wpi::span<Subsystem* const> requirements) {
std::span<Subsystem* const> requirements) {
WhileActiveContinous(std::move(toRun), requirements);
return *this;
}
@@ -79,7 +79,7 @@ Button Button::WhenReleased(std::function<void()> toRun,
}
Button Button::WhenReleased(std::function<void()> toRun,
wpi::span<Subsystem* const> requirements) {
std::span<Subsystem* const> requirements) {
WhenInactive(std::move(toRun), requirements);
return *this;
}

View File

@@ -30,7 +30,7 @@ Trigger Trigger::WhenActive(std::function<void()> toRun,
}
Trigger Trigger::WhenActive(std::function<void()> toRun,
wpi::span<Subsystem* const> requirements) {
std::span<Subsystem* const> requirements) {
return WhenActive(InstantCommand(std::move(toRun), requirements));
}
@@ -55,7 +55,7 @@ Trigger Trigger::WhileActiveContinous(
}
Trigger Trigger::WhileActiveContinous(
std::function<void()> toRun, wpi::span<Subsystem* const> requirements) {
std::function<void()> toRun, std::span<Subsystem* const> requirements) {
return WhileActiveContinous(InstantCommand(std::move(toRun), requirements));
}
@@ -90,7 +90,7 @@ Trigger Trigger::WhenInactive(std::function<void()> toRun,
}
Trigger Trigger::WhenInactive(std::function<void()> toRun,
wpi::span<Subsystem* const> requirements) {
std::span<Subsystem* const> requirements) {
return WhenInactive(InstantCommand(std::move(toRun), requirements));
}

View File

@@ -7,13 +7,13 @@
#include <functional>
#include <initializer_list>
#include <memory>
#include <span>
#include <string>
#include <units/time.h>
#include <wpi/Demangle.h>
#include <wpi/SmallSet.h>
#include <wpi/deprecated.h>
#include <wpi/span.h>
#include "frc2/command/Subsystem.h"
@@ -171,7 +171,7 @@ class Command {
*/
[[nodiscard]] CommandPtr BeforeStarting(
std::function<void()> toRun,
wpi::span<Subsystem* const> requirements = {}) &&;
std::span<Subsystem* const> requirements = {}) &&;
/**
* Decorates this command with a runnable to run after the command finishes.
@@ -193,7 +193,7 @@ class Command {
*/
[[nodiscard]] CommandPtr AndThen(
std::function<void()> toRun,
wpi::span<Subsystem* const> requirements = {}) &&;
std::span<Subsystem* const> requirements = {}) &&;
/**
* Decorates this command to run perpetually, ignoring its ordinary end

View File

@@ -5,13 +5,13 @@
#pragma once
#include <initializer_list>
#include <span>
#include <string>
#include <string_view>
#include <wpi/SmallSet.h>
#include <wpi/sendable/Sendable.h>
#include <wpi/sendable/SendableHelper.h>
#include <wpi/span.h>
#include "frc2/command/Command.h"
@@ -37,7 +37,7 @@ class CommandBase : public Command,
*
* @param requirements the Subsystem requirements to add
*/
void AddRequirements(wpi::span<Subsystem* const> requirements);
void AddRequirements(std::span<Subsystem* const> requirements);
/**
* Adds the specified Subsystem requirements to the command.

View File

@@ -6,10 +6,9 @@
#include <initializer_list>
#include <memory>
#include <span>
#include <vector>
#include <wpi/span.h>
#include "frc2/command/CommandBase.h"
namespace frc2 {
@@ -49,7 +48,7 @@ class CommandGroupBase : public CommandBase {
* @return True if all the commands are ungrouped.
*/
static bool RequireUngrouped(
wpi::span<const std::unique_ptr<Command>> commands);
std::span<const std::unique_ptr<Command>> commands);
/**
* Requires that the specified commands not have been already allocated to a

View File

@@ -7,6 +7,7 @@
#include <functional>
#include <initializer_list>
#include <memory>
#include <span>
#include <utility>
#include <vector>
@@ -89,7 +90,7 @@ class CommandPtr final {
*/
[[nodiscard]] CommandPtr AndThen(
std::function<void()> toRun,
wpi::span<Subsystem* const> requirements = {}) &&;
std::span<Subsystem* const> requirements = {}) &&;
/**
* Decorates this command with a runnable to run after the command finishes.
@@ -132,7 +133,7 @@ class CommandPtr final {
*/
[[nodiscard]] CommandPtr BeforeStarting(
std::function<void()> toRun,
wpi::span<Subsystem* const> requirements = {}) &&;
std::span<Subsystem* const> requirements = {}) &&;
/**
* Decorates this command with another command to run before this command

View File

@@ -6,6 +6,7 @@
#include <initializer_list>
#include <memory>
#include <span>
#include <utility>
#include <frc/Errors.h>
@@ -16,7 +17,6 @@
#include <wpi/FunctionExtras.h>
#include <wpi/deprecated.h>
#include <wpi/sendable/SendableHelper.h>
#include <wpi/span.h>
namespace frc2 {
class Command;
@@ -111,7 +111,7 @@ class CommandScheduler final : public nt::NTSendable,
*
* @param commands the commands to schedule
*/
void Schedule(wpi::span<Command* const> commands);
void Schedule(std::span<Command* const> commands);
/**
* Schedules multiple commands for execution. Does nothing for commands
@@ -159,10 +159,10 @@ class CommandScheduler final : public nt::NTSendable,
void UnregisterSubsystem(Subsystem* subsystem);
void RegisterSubsystem(std::initializer_list<Subsystem*> subsystems);
void RegisterSubsystem(wpi::span<Subsystem* const> subsystems);
void RegisterSubsystem(std::span<Subsystem* const> subsystems);
void UnregisterSubsystem(std::initializer_list<Subsystem*> subsystems);
void UnregisterSubsystem(wpi::span<Subsystem* const> subsystems);
void UnregisterSubsystem(std::span<Subsystem* const> subsystems);
/**
* Sets the default command for a subsystem. Registers that subsystem if it
@@ -234,7 +234,7 @@ class CommandScheduler final : public nt::NTSendable,
*
* @param commands the commands to cancel
*/
void Cancel(wpi::span<Command* const> commands);
void Cancel(std::span<Command* const> commands);
/**
* Cancels commands. The scheduler will only call Command::End()
@@ -261,7 +261,7 @@ class CommandScheduler final : public nt::NTSendable,
* @param commands the command to query
* @return whether the command is currently scheduled
*/
bool IsScheduled(wpi::span<const Command* const> commands) const;
bool IsScheduled(std::span<const Command* const> commands) const;
/**
* Whether the given commands are running. Note that this only works on

View File

@@ -6,8 +6,7 @@
#include <functional>
#include <initializer_list>
#include <wpi/span.h>
#include <span>
#include "frc2/command/CommandBase.h"
#include "frc2/command/CommandHelper.h"
@@ -54,7 +53,7 @@ class FunctionalCommand : public CommandHelper<CommandBase, FunctionalCommand> {
std::function<void()> onExecute,
std::function<void(bool)> onEnd,
std::function<bool()> isFinished,
wpi::span<Subsystem* const> requirements = {});
std::span<Subsystem* const> requirements = {});
FunctionalCommand(FunctionalCommand&& other) = default;

View File

@@ -6,8 +6,7 @@
#include <functional>
#include <initializer_list>
#include <wpi/span.h>
#include <span>
#include "frc2/command/CommandHelper.h"
#include "frc2/command/FunctionalCommand.h"
@@ -40,7 +39,7 @@ class InstantCommand : public CommandHelper<FunctionalCommand, InstantCommand> {
* @param requirements the subsystems required by this command
*/
explicit InstantCommand(std::function<void()> toRun,
wpi::span<Subsystem* const> requirements = {});
std::span<Subsystem* const> requirements = {});
InstantCommand(InstantCommand&& other) = default;

View File

@@ -6,6 +6,7 @@
#include <functional>
#include <initializer_list>
#include <memory>
#include <span>
#include <frc/Timer.h>
#include <frc/controller/HolonomicDriveController.h>
@@ -21,7 +22,6 @@
#include <units/length.h>
#include <units/velocity.h>
#include <units/voltage.h>
#include <wpi/span.h>
#include "CommandBase.h"
#include "CommandHelper.h"
@@ -206,7 +206,7 @@ class MecanumControllerCommand
std::function<void(units::volt_t, units::volt_t, units::volt_t,
units::volt_t)>
output,
wpi::span<Subsystem* const> requirements = {});
std::span<Subsystem* const> requirements = {});
/**
* Constructs a new MecanumControllerCommand that when executed will follow
@@ -259,7 +259,7 @@ class MecanumControllerCommand
std::function<void(units::volt_t, units::volt_t, units::volt_t,
units::volt_t)>
output,
wpi::span<Subsystem* const> requirements = {});
std::span<Subsystem* const> requirements = {});
/**
* Constructs a new MecanumControllerCommand that when executed will follow
@@ -375,7 +375,7 @@ class MecanumControllerCommand
units::meters_per_second_t,
units::meters_per_second_t)>
output,
wpi::span<Subsystem* const> requirements = {});
std::span<Subsystem* const> requirements = {});
/**
* Constructs a new MecanumControllerCommand that when executed will follow
@@ -415,7 +415,7 @@ class MecanumControllerCommand
units::meters_per_second_t,
units::meters_per_second_t)>
output,
wpi::span<Subsystem* const> requirements = {});
std::span<Subsystem* const> requirements = {});
void Initialize() override;

View File

@@ -6,10 +6,10 @@
#include <functional>
#include <initializer_list>
#include <span>
#include <frc/Notifier.h>
#include <units/time.h>
#include <wpi/span.h>
#include "frc2/command/CommandBase.h"
#include "frc2/command/CommandHelper.h"
@@ -47,7 +47,7 @@ class NotifierCommand : public CommandHelper<CommandBase, NotifierCommand> {
* @param requirements the subsystems required by this command
*/
NotifierCommand(std::function<void()> toRun, units::second_t period,
wpi::span<Subsystem* const> requirements = {});
std::span<Subsystem* const> requirements = {});
NotifierCommand(NotifierCommand&& other);

View File

@@ -6,9 +6,9 @@
#include <functional>
#include <initializer_list>
#include <span>
#include <frc/controller/PIDController.h>
#include <wpi/span.h>
#include "frc2/command/CommandBase.h"
#include "frc2/command/CommandHelper.h"
@@ -56,7 +56,7 @@ class PIDCommand : public CommandHelper<CommandBase, PIDCommand> {
std::function<double()> measurementSource,
std::function<double()> setpointSource,
std::function<void(double)> useOutput,
wpi::span<Subsystem* const> requirements = {});
std::span<Subsystem* const> requirements = {});
/**
* Creates a new PIDCommand, which controls the given output with a
@@ -86,7 +86,7 @@ class PIDCommand : public CommandHelper<CommandBase, PIDCommand> {
PIDCommand(PIDController controller,
std::function<double()> measurementSource, double setpoint,
std::function<void(double)> useOutput,
wpi::span<Subsystem* const> requirements = {});
std::span<Subsystem* const> requirements = {});
PIDCommand(PIDCommand&& other) = default;

View File

@@ -6,11 +6,11 @@
#include <functional>
#include <initializer_list>
#include <span>
#include <utility>
#include <frc/controller/ProfiledPIDController.h>
#include <units/time.h>
#include <wpi/span.h>
#include "frc2/command/CommandBase.h"
#include "frc2/command/CommandHelper.h"
@@ -72,7 +72,7 @@ class ProfiledPIDCommand
std::function<Distance_t()> measurementSource,
std::function<State()> goalSource,
std::function<void(double, State)> useOutput,
wpi::span<Subsystem* const> requirements = {})
std::span<Subsystem* const> requirements = {})
: m_controller{controller},
m_measurement{std::move(measurementSource)},
m_goal{std::move(goalSource)},
@@ -116,7 +116,7 @@ class ProfiledPIDCommand
std::function<Distance_t()> measurementSource,
std::function<Distance_t()> goalSource,
std::function<void(double, State)> useOutput,
wpi::span<Subsystem* const> requirements = {})
std::span<Subsystem* const> requirements = {})
: ProfiledPIDCommand(
controller, measurementSource,
[goalSource = std::move(goalSource)]() {
@@ -155,7 +155,7 @@ class ProfiledPIDCommand
ProfiledPIDCommand(frc::ProfiledPIDController<Distance> controller,
std::function<Distance_t()> measurementSource, State goal,
std::function<void(double, State)> useOutput,
wpi::span<Subsystem* const> requirements = {})
std::span<Subsystem* const> requirements = {})
: ProfiledPIDCommand(
controller, measurementSource, [goal] { return goal; }, useOutput,
requirements) {}
@@ -193,7 +193,7 @@ class ProfiledPIDCommand
std::function<Distance_t()> measurementSource,
Distance_t goal,
std::function<void(double, State)> useOutput,
wpi::span<Subsystem* const> requirements = {})
std::span<Subsystem* const> requirements = {})
: ProfiledPIDCommand(
controller, measurementSource, [goal] { return goal; }, useOutput,
requirements) {}

View File

@@ -5,9 +5,9 @@
#pragma once
#include <memory>
#include <span>
#include <wpi/SmallVector.h>
#include <wpi/span.h>
#include "frc2/command/CommandBase.h"
#include "frc2/command/CommandHelper.h"
@@ -31,7 +31,7 @@ class ProxyScheduleCommand
*
* @param toSchedule the commands to schedule
*/
explicit ProxyScheduleCommand(wpi::span<Command* const> toSchedule);
explicit ProxyScheduleCommand(std::span<Command* const> toSchedule);
explicit ProxyScheduleCommand(Command* toSchedule);

View File

@@ -7,6 +7,7 @@
#include <functional>
#include <initializer_list>
#include <memory>
#include <span>
#include <frc/Timer.h>
#include <frc/controller/PIDController.h>
@@ -17,7 +18,6 @@
#include <frc/trajectory/Trajectory.h>
#include <units/length.h>
#include <units/voltage.h>
#include <wpi/span.h>
#include "frc2/command/CommandBase.h"
#include "frc2/command/CommandHelper.h"
@@ -116,7 +116,7 @@ class RamseteCommand : public CommandHelper<CommandBase, RamseteCommand> {
frc2::PIDController leftController,
frc2::PIDController rightController,
std::function<void(units::volt_t, units::volt_t)> output,
wpi::span<Subsystem* const> requirements = {});
std::span<Subsystem* const> requirements = {});
/**
* Constructs a new RamseteCommand that, when executed, will follow the
@@ -164,7 +164,7 @@ class RamseteCommand : public CommandHelper<CommandBase, RamseteCommand> {
std::function<void(units::meters_per_second_t,
units::meters_per_second_t)>
output,
wpi::span<Subsystem* const> requirements = {});
std::span<Subsystem* const> requirements = {});
void Initialize() override;

View File

@@ -6,8 +6,7 @@
#include <functional>
#include <initializer_list>
#include <wpi/span.h>
#include <span>
#include "frc2/command/CommandHelper.h"
#include "frc2/command/FunctionalCommand.h"
@@ -41,7 +40,7 @@ class RunCommand : public CommandHelper<FunctionalCommand, RunCommand> {
* @param requirements the subsystems to require
*/
explicit RunCommand(std::function<void()> toRun,
wpi::span<Subsystem* const> requirements = {});
std::span<Subsystem* const> requirements = {});
RunCommand(RunCommand&& other) = default;

View File

@@ -4,8 +4,9 @@
#pragma once
#include <span>
#include <wpi/SmallVector.h>
#include <wpi/span.h>
#include "frc2/command/CommandBase.h"
#include "frc2/command/CommandHelper.h"
@@ -28,7 +29,7 @@ class ScheduleCommand : public CommandHelper<CommandBase, ScheduleCommand> {
*
* @param toSchedule the commands to schedule
*/
explicit ScheduleCommand(wpi::span<Command* const> toSchedule);
explicit ScheduleCommand(std::span<Command* const> toSchedule);
explicit ScheduleCommand(Command* toSchedule);

View File

@@ -11,6 +11,7 @@
#include <limits>
#include <memory>
#include <span>
#include <type_traits>
#include <utility>
#include <vector>

View File

@@ -4,12 +4,13 @@
#pragma once
#include <span>
#include <wpi/SmallVector.h>
#include <wpi/span.h>
namespace frc2 {
template <typename T>
void SetInsert(wpi::SmallVectorImpl<T*>& vector, wpi::span<T* const> toAdd) {
void SetInsert(wpi::SmallVectorImpl<T*>& vector, std::span<T* const> toAdd) {
for (auto addCommand : toAdd) {
bool exists = false;
for (auto existingCommand : vector) {

View File

@@ -6,8 +6,7 @@
#include <functional>
#include <initializer_list>
#include <wpi/span.h>
#include <span>
#include "frc2/command/CommandHelper.h"
#include "frc2/command/FunctionalCommand.h"
@@ -45,7 +44,7 @@ class StartEndCommand
* @param requirements the subsystems required by this command
*/
StartEndCommand(std::function<void()> onInit, std::function<void()> onEnd,
wpi::span<Subsystem* const> requirements = {});
std::span<Subsystem* const> requirements = {});
StartEndCommand(StartEndCommand&& other) = default;

View File

@@ -6,6 +6,7 @@
#include <functional>
#include <initializer_list>
#include <memory>
#include <span>
#include <frc/Timer.h>
#include <frc/controller/HolonomicDriveController.h>
@@ -19,7 +20,6 @@
#include <units/length.h>
#include <units/time.h>
#include <units/voltage.h>
#include <wpi/span.h>
#include "CommandBase.h"
#include "CommandHelper.h"
@@ -169,7 +169,7 @@ class SwerveControllerCommand
std::function<frc::Rotation2d()> desiredRotation,
std::function<void(std::array<frc::SwerveModuleState, NumModules>)>
output,
wpi::span<Subsystem* const> requirements = {});
std::span<Subsystem* const> requirements = {});
/**
* Constructs a new SwerveControllerCommand that when executed will follow the
@@ -207,7 +207,7 @@ class SwerveControllerCommand
frc::ProfiledPIDController<units::radians> thetaController,
std::function<void(std::array<frc::SwerveModuleState, NumModules>)>
output,
wpi::span<Subsystem* const> requirements = {});
std::span<Subsystem* const> requirements = {});
void Initialize() override;

View File

@@ -53,7 +53,7 @@ SwerveControllerCommand<NumModules>::SwerveControllerCommand(
frc::ProfiledPIDController<units::radians> thetaController,
std::function<frc::Rotation2d()> desiredRotation,
std::function<void(std::array<frc::SwerveModuleState, NumModules>)> output,
wpi::span<Subsystem* const> requirements)
std::span<Subsystem* const> requirements)
: m_trajectory(std::move(trajectory)),
m_pose(std::move(pose)),
m_kinematics(kinematics),
@@ -70,7 +70,7 @@ SwerveControllerCommand<NumModules>::SwerveControllerCommand(
frc2::PIDController xController, frc2::PIDController yController,
frc::ProfiledPIDController<units::radians> thetaController,
std::function<void(std::array<frc::SwerveModuleState, NumModules>)> output,
wpi::span<Subsystem* const> requirements)
std::span<Subsystem* const> requirements)
: m_trajectory(std::move(trajectory)),
m_pose(std::move(pose)),
m_kinematics(kinematics),

View File

@@ -6,10 +6,10 @@
#include <functional>
#include <initializer_list>
#include <span>
#include <frc/Timer.h>
#include <frc/trajectory/TrapezoidProfile.h>
#include <wpi/span.h>
#include "frc2/command/CommandBase.h"
#include "frc2/command/CommandHelper.h"
@@ -58,7 +58,7 @@ class TrapezoidProfileCommand
*/
TrapezoidProfileCommand(frc::TrapezoidProfile<Distance> profile,
std::function<void(State)> output,
wpi::span<Subsystem* const> requirements = {})
std::span<Subsystem* const> requirements = {})
: m_profile(profile), m_output(output) {
this->AddRequirements(requirements);
}

View File

@@ -6,10 +6,9 @@
#include <functional>
#include <initializer_list>
#include <span>
#include <utility>
#include <wpi/span.h>
#include "Trigger.h"
#include "frc2/command/CommandPtr.h"
@@ -90,7 +89,7 @@ class Button : public Trigger {
* @param requirements the required subsystems.
*/
Button WhenPressed(std::function<void()> toRun,
wpi::span<Subsystem* const> requirements = {});
std::span<Subsystem* const> requirements = {});
/**
* Binds a command to be started repeatedly while the button is pressed, and
@@ -144,7 +143,7 @@ class Button : public Trigger {
* @param requirements the required subsystems.
*/
Button WhileHeld(std::function<void()> toRun,
wpi::span<Subsystem* const> requirements = {});
std::span<Subsystem* const> requirements = {});
/**
* Binds a command to be started when the button is pressed, and canceled
@@ -234,7 +233,7 @@ class Button : public Trigger {
* @param requirements the required subsystems.
*/
Button WhenReleased(std::function<void()> toRun,
wpi::span<Subsystem* const> requirements = {});
std::span<Subsystem* const> requirements = {});
/**
* Binds a command to start when the button is pressed, and be canceled when

View File

@@ -7,13 +7,13 @@
#include <functional>
#include <initializer_list>
#include <memory>
#include <span>
#include <utility>
#include <frc/event/BooleanEvent.h>
#include <frc/event/EventLoop.h>
#include <frc/filter/Debouncer.h>
#include <units/time.h>
#include <wpi/span.h>
#include "frc2/command/Command.h"
#include "frc2/command/CommandScheduler.h"
@@ -113,7 +113,7 @@ class Trigger : public frc::BooleanEvent {
* @param requirements the required subsystems.
*/
Trigger WhenActive(std::function<void()> toRun,
wpi::span<Subsystem* const> requirements = {});
std::span<Subsystem* const> requirements = {});
/**
* Binds a command to be started repeatedly while the trigger is active, and
@@ -171,7 +171,7 @@ class Trigger : public frc::BooleanEvent {
* @param requirements the required subsystems.
*/
Trigger WhileActiveContinous(std::function<void()> toRun,
wpi::span<Subsystem* const> requirements = {});
std::span<Subsystem* const> requirements = {});
/**
* Binds a command to be started when the trigger becomes active, and
@@ -268,7 +268,7 @@ class Trigger : public frc::BooleanEvent {
* @param requirements the required subsystems.
*/
Trigger WhenInactive(std::function<void()> toRun,
wpi::span<Subsystem* const> requirements = {});
std::span<Subsystem* const> requirements = {});
/**
* Binds a command to start when the trigger becomes active, and be canceled