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

@@ -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