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));
}