diff --git a/cscore/src/main/native/cpp/Instance.h b/cscore/src/main/native/cpp/Instance.h index b3e40efaa4..66ede809ee 100644 --- a/cscore/src/main/native/cpp/Instance.h +++ b/cscore/src/main/native/cpp/Instance.h @@ -23,7 +23,7 @@ namespace cs { struct SourceData { SourceData(CS_SourceKind kind_, std::shared_ptr source_) - : kind{kind_}, refCount{0}, source{source_} {} + : kind{kind_}, refCount{0}, source{std::move(source_)} {} CS_SourceKind kind; std::atomic_int refCount; @@ -32,7 +32,7 @@ struct SourceData { struct SinkData { explicit SinkData(CS_SinkKind kind_, std::shared_ptr sink_) - : kind{kind_}, refCount{0}, sourceHandle{0}, sink{sink_} {} + : kind{kind_}, refCount{0}, sourceHandle{0}, sink{std::move(sink_)} {} CS_SinkKind kind; std::atomic_int refCount; diff --git a/cscore/src/main/native/cpp/Notifier.cpp b/cscore/src/main/native/cpp/Notifier.cpp index d385bb583c..49f0c49928 100644 --- a/cscore/src/main/native/cpp/Notifier.cpp +++ b/cscore/src/main/native/cpp/Notifier.cpp @@ -5,6 +5,7 @@ #include "Notifier.h" #include +#include #include #include "Handle.h" @@ -66,7 +67,7 @@ class UidVector { class Notifier::Thread : public wpi::SafeThread { public: Thread(std::function on_start, std::function on_exit) - : m_on_start(on_start), m_on_exit(on_exit) {} + : m_on_start(std::move(on_start)), m_on_exit(std::move(on_exit)) {} void Main() override; @@ -74,7 +75,7 @@ class Notifier::Thread : public wpi::SafeThread { Listener() = default; Listener(std::function callback_, int eventMask_) - : callback(callback_), eventMask(eventMask_) {} + : callback(std::move(callback_)), eventMask(eventMask_) {} explicit operator bool() const { return static_cast(callback); } diff --git a/ntcore/src/main/native/cpp/NetworkConnection.cpp b/ntcore/src/main/native/cpp/NetworkConnection.cpp index 16f9be8118..38a909e9ef 100644 --- a/ntcore/src/main/native/cpp/NetworkConnection.cpp +++ b/ntcore/src/main/native/cpp/NetworkConnection.cpp @@ -4,6 +4,8 @@ #include "NetworkConnection.h" +#include + #include #include #include @@ -25,8 +27,8 @@ NetworkConnection::NetworkConnection(unsigned int uid, m_stream(std::move(stream)), m_notifier(notifier), m_logger(logger), - m_handshake(handshake), - m_get_entry_type(get_entry_type), + m_handshake(std::move(handshake)), + m_get_entry_type(std::move(get_entry_type)), m_state(kCreated) { m_active = false; m_proto_rev = 0x0300; diff --git a/ntcore/src/main/native/cpp/RpcServer.h b/ntcore/src/main/native/cpp/RpcServer.h index a437bbe158..301bbff106 100644 --- a/ntcore/src/main/native/cpp/RpcServer.h +++ b/ntcore/src/main/native/cpp/RpcServer.h @@ -26,7 +26,7 @@ struct RpcNotifierData : public RpcAnswer { StringRef params_, const ConnectionInfo& conn_, IRpcServer::SendResponseFunc send_response_) : RpcAnswer{entry_, call_, name_, params_, conn_}, - send_response{send_response_} {} + send_response{std::move(send_response_)} {} IRpcServer::SendResponseFunc send_response; }; diff --git a/ntcore/src/main/native/cpp/Storage_load.cpp b/ntcore/src/main/native/cpp/Storage_load.cpp index 1a1a8feebc..956321d60f 100644 --- a/ntcore/src/main/native/cpp/Storage_load.cpp +++ b/ntcore/src/main/native/cpp/Storage_load.cpp @@ -4,6 +4,7 @@ #include #include +#include #include #include @@ -24,7 +25,7 @@ class LoadPersistentImpl { using WarnFunc = std::function; LoadPersistentImpl(wpi::raw_istream& is, WarnFunc warn) - : m_is(is), m_warn(warn) {} + : m_is(is), m_warn(std::move(warn)) {} bool Load(StringRef prefix, std::vector* entries); diff --git a/ntcore/src/main/native/include/ntcore_cpp.h b/ntcore/src/main/native/include/ntcore_cpp.h index 1700a2b88f..3964975797 100644 --- a/ntcore/src/main/native/include/ntcore_cpp.h +++ b/ntcore/src/main/native/include/ntcore_cpp.h @@ -104,7 +104,7 @@ struct ConnectionInfo { struct RpcParamDef { RpcParamDef() = default; RpcParamDef(StringRef name_, std::shared_ptr def_value_) - : name(name_), def_value(def_value_) {} + : name(name_), def_value(std::move(def_value_)) {} std::string name; std::shared_ptr def_value; @@ -132,8 +132,12 @@ class RpcAnswer { public: RpcAnswer() = default; RpcAnswer(NT_Entry entry_, NT_RpcCall call_, StringRef name_, - StringRef params_, const ConnectionInfo& conn_) - : entry(entry_), call(call_), name(name_), params(params_), conn(conn_) {} + StringRef params_, ConnectionInfo conn_) + : entry(entry_), + call(call_), + name(name_), + params(params_), + conn(std::move(conn_)) {} /** Entry handle. */ NT_Entry entry{0}; @@ -183,7 +187,7 @@ class EntryNotification { : listener(listener_), entry(entry_), name(name_), - value(value_), + value(std::move(value_)), flags(flags_) {} /** Listener that was triggered. */ @@ -219,8 +223,8 @@ class ConnectionNotification { public: ConnectionNotification() = default; ConnectionNotification(NT_ConnectionListener listener_, bool connected_, - const ConnectionInfo& conn_) - : listener(listener_), connected(connected_), conn(conn_) {} + ConnectionInfo conn_) + : listener(listener_), connected(connected_), conn(std::move(conn_)) {} /** Listener that was triggered. */ NT_ConnectionListener listener{0}; diff --git a/ntcore/src/test/native/cpp/MessageMatcher.h b/ntcore/src/test/native/cpp/MessageMatcher.h index 6984e4c06f..7afeeef9f9 100644 --- a/ntcore/src/test/native/cpp/MessageMatcher.h +++ b/ntcore/src/test/native/cpp/MessageMatcher.h @@ -7,6 +7,7 @@ #include #include +#include #include "Message.h" #include "TestPrinters.h" @@ -18,7 +19,7 @@ class MessageMatcher : public ::testing::MatcherInterface> { public: explicit MessageMatcher(std::shared_ptr goodmsg_) - : goodmsg(goodmsg_) {} + : goodmsg(std::move(goodmsg_)) {} bool MatchAndExplain(std::shared_ptr msg, ::testing::MatchResultListener* listener) const override; diff --git a/ntcore/src/test/native/cpp/ValueMatcher.h b/ntcore/src/test/native/cpp/ValueMatcher.h index 15a2026dc7..ab68448d49 100644 --- a/ntcore/src/test/native/cpp/ValueMatcher.h +++ b/ntcore/src/test/native/cpp/ValueMatcher.h @@ -7,6 +7,7 @@ #include #include +#include #include "gmock/gmock.h" #include "networktables/NetworkTableValue.h" @@ -16,7 +17,8 @@ namespace nt { class ValueMatcher : public ::testing::MatcherInterface> { public: - explicit ValueMatcher(std::shared_ptr goodval_) : goodval(goodval_) {} + explicit ValueMatcher(std::shared_ptr goodval_) + : goodval(std::move(goodval_)) {} bool MatchAndExplain(std::shared_ptr msg, ::testing::MatchResultListener* listener) const override; diff --git a/simulation/halsim_ws_core/src/main/native/cpp/WSBaseProvider.cpp b/simulation/halsim_ws_core/src/main/native/cpp/WSBaseProvider.cpp index 552d4f24ee..2e93f96ff1 100644 --- a/simulation/halsim_ws_core/src/main/native/cpp/WSBaseProvider.cpp +++ b/simulation/halsim_ws_core/src/main/native/cpp/WSBaseProvider.cpp @@ -4,11 +4,12 @@ #include "WSBaseProvider.h" +#include + namespace wpilibws { -HALSimWSBaseProvider::HALSimWSBaseProvider(const std::string& key, - const std::string& type) - : m_key(key), m_type(type) {} +HALSimWSBaseProvider::HALSimWSBaseProvider(std::string key, std::string type) + : m_key(std::move(key)), m_type(std::move(type)) {} void HALSimWSBaseProvider::OnNetValueChanged(const wpi::json& json) { // empty diff --git a/simulation/halsim_ws_core/src/main/native/include/WSBaseProvider.h b/simulation/halsim_ws_core/src/main/native/include/WSBaseProvider.h index a0c47b5f95..39fadb6708 100644 --- a/simulation/halsim_ws_core/src/main/native/include/WSBaseProvider.h +++ b/simulation/halsim_ws_core/src/main/native/include/WSBaseProvider.h @@ -16,8 +16,7 @@ namespace wpilibws { class HALSimWSBaseProvider { public: - explicit HALSimWSBaseProvider(const std::string& key, - const std::string& type = ""); + explicit HALSimWSBaseProvider(std::string key, std::string type = ""); virtual ~HALSimWSBaseProvider() = default; HALSimWSBaseProvider(const HALSimWSBaseProvider&) = delete; diff --git a/wpilibNewCommands/src/main/native/cpp/frc2/command/MecanumControllerCommand.cpp b/wpilibNewCommands/src/main/native/cpp/frc2/command/MecanumControllerCommand.cpp index 1af0bf8c6b..f5e1cc178c 100644 --- a/wpilibNewCommands/src/main/native/cpp/frc2/command/MecanumControllerCommand.cpp +++ b/wpilibNewCommands/src/main/native/cpp/frc2/command/MecanumControllerCommand.cpp @@ -4,6 +4,8 @@ #include "frc2/command/MecanumControllerCommand.h" +#include + using namespace frc2; using namespace units; @@ -24,12 +26,12 @@ MecanumControllerCommand::MecanumControllerCommand( units::volt_t)> output, std::initializer_list requirements) - : m_trajectory(trajectory), - m_pose(pose), + : m_trajectory(std::move(trajectory)), + m_pose(std::move(pose)), m_feedforward(feedforward), m_kinematics(kinematics), m_controller(xController, yController, thetaController), - m_desiredRotation(desiredRotation), + m_desiredRotation(std::move(desiredRotation)), m_maxWheelVelocity(maxWheelVelocity), m_frontLeftController( std::make_unique(frontLeftController)), @@ -39,8 +41,8 @@ MecanumControllerCommand::MecanumControllerCommand( std::make_unique(frontRightController)), m_rearRightController( std::make_unique(rearRightController)), - m_currentWheelSpeeds(currentWheelSpeeds), - m_outputVolts(output), + m_currentWheelSpeeds(std::move(currentWheelSpeeds)), + m_outputVolts(std::move(output)), m_usePID(true) { AddRequirements(requirements); } @@ -61,8 +63,8 @@ MecanumControllerCommand::MecanumControllerCommand( units::volt_t)> output, std::initializer_list requirements) - : m_trajectory(trajectory), - m_pose(pose), + : m_trajectory(std::move(trajectory)), + m_pose(std::move(pose)), m_feedforward(feedforward), m_kinematics(kinematics), m_controller(xController, yController, thetaController), @@ -75,8 +77,8 @@ MecanumControllerCommand::MecanumControllerCommand( std::make_unique(frontRightController)), m_rearRightController( std::make_unique(rearRightController)), - m_currentWheelSpeeds(currentWheelSpeeds), - m_outputVolts(output), + m_currentWheelSpeeds(std::move(currentWheelSpeeds)), + m_outputVolts(std::move(output)), m_usePID(true) { AddRequirements(requirements); m_desiredRotation = [&] { @@ -101,12 +103,12 @@ MecanumControllerCommand::MecanumControllerCommand( units::volt_t)> output, wpi::ArrayRef requirements) - : m_trajectory(trajectory), - m_pose(pose), + : m_trajectory(std::move(trajectory)), + m_pose(std::move(pose)), m_feedforward(feedforward), m_kinematics(kinematics), m_controller(xController, yController, thetaController), - m_desiredRotation(desiredRotation), + m_desiredRotation(std::move(desiredRotation)), m_maxWheelVelocity(maxWheelVelocity), m_frontLeftController( std::make_unique(frontLeftController)), @@ -116,8 +118,8 @@ MecanumControllerCommand::MecanumControllerCommand( std::make_unique(frontRightController)), m_rearRightController( std::make_unique(rearRightController)), - m_currentWheelSpeeds(currentWheelSpeeds), - m_outputVolts(output), + m_currentWheelSpeeds(std::move(currentWheelSpeeds)), + m_outputVolts(std::move(output)), m_usePID(true) { AddRequirements(requirements); } @@ -138,8 +140,8 @@ MecanumControllerCommand::MecanumControllerCommand( units::volt_t)> output, wpi::ArrayRef requirements) - : m_trajectory(trajectory), - m_pose(pose), + : m_trajectory(std::move(trajectory)), + m_pose(std::move(pose)), m_feedforward(feedforward), m_kinematics(kinematics), m_controller(xController, yController, thetaController), @@ -152,8 +154,8 @@ MecanumControllerCommand::MecanumControllerCommand( std::make_unique(frontRightController)), m_rearRightController( std::make_unique(rearRightController)), - m_currentWheelSpeeds(currentWheelSpeeds), - m_outputVolts(output), + m_currentWheelSpeeds(std::move(currentWheelSpeeds)), + m_outputVolts(std::move(output)), m_usePID(true) { AddRequirements(requirements); m_desiredRotation = [&] { @@ -172,13 +174,13 @@ MecanumControllerCommand::MecanumControllerCommand( units::meters_per_second_t, units::meters_per_second_t)> output, std::initializer_list requirements) - : m_trajectory(trajectory), - m_pose(pose), + : m_trajectory(std::move(trajectory)), + m_pose(std::move(pose)), m_kinematics(kinematics), m_controller(xController, yController, thetaController), - m_desiredRotation(desiredRotation), + m_desiredRotation(std::move(desiredRotation)), m_maxWheelVelocity(maxWheelVelocity), - m_outputVel(output), + m_outputVel(std::move(output)), m_usePID(false) { AddRequirements(requirements); } @@ -193,12 +195,12 @@ MecanumControllerCommand::MecanumControllerCommand( units::meters_per_second_t, units::meters_per_second_t)> output, std::initializer_list requirements) - : m_trajectory(trajectory), - m_pose(pose), + : m_trajectory(std::move(trajectory)), + m_pose(std::move(pose)), m_kinematics(kinematics), m_controller(xController, yController, thetaController), m_maxWheelVelocity(maxWheelVelocity), - m_outputVel(output), + m_outputVel(std::move(output)), m_usePID(false) { AddRequirements(requirements); m_desiredRotation = [&] { @@ -217,13 +219,13 @@ MecanumControllerCommand::MecanumControllerCommand( units::meters_per_second_t, units::meters_per_second_t)> output, wpi::ArrayRef requirements) - : m_trajectory(trajectory), - m_pose(pose), + : m_trajectory(std::move(trajectory)), + m_pose(std::move(pose)), m_kinematics(kinematics), m_controller(xController, yController, thetaController), - m_desiredRotation(desiredRotation), + m_desiredRotation(std::move(desiredRotation)), m_maxWheelVelocity(maxWheelVelocity), - m_outputVel(output), + m_outputVel(std::move(output)), m_usePID(false) { AddRequirements(requirements); } @@ -238,12 +240,12 @@ MecanumControllerCommand::MecanumControllerCommand( units::meters_per_second_t, units::meters_per_second_t)> output, wpi::ArrayRef requirements) - : m_trajectory(trajectory), - m_pose(pose), + : m_trajectory(std::move(trajectory)), + m_pose(std::move(pose)), m_kinematics(kinematics), m_controller(xController, yController, thetaController), m_maxWheelVelocity(maxWheelVelocity), - m_outputVel(output), + m_outputVel(std::move(output)), m_usePID(false) { AddRequirements(requirements); m_desiredRotation = [&] { diff --git a/wpilibNewCommands/src/main/native/cpp/frc2/command/PIDCommand.cpp b/wpilibNewCommands/src/main/native/cpp/frc2/command/PIDCommand.cpp index 10cb99cfd4..5e13ee0d04 100644 --- a/wpilibNewCommands/src/main/native/cpp/frc2/command/PIDCommand.cpp +++ b/wpilibNewCommands/src/main/native/cpp/frc2/command/PIDCommand.cpp @@ -4,6 +4,8 @@ #include "frc2/command/PIDCommand.h" +#include + using namespace frc2; PIDCommand::PIDCommand(PIDController controller, @@ -11,7 +13,7 @@ PIDCommand::PIDCommand(PIDController controller, std::function setpointSource, std::function useOutput, std::initializer_list requirements) - : m_controller{controller}, + : m_controller{std::move(controller)}, m_measurement{std::move(measurementSource)}, m_setpoint{std::move(setpointSource)}, m_useOutput{std::move(useOutput)} { @@ -23,7 +25,7 @@ PIDCommand::PIDCommand(PIDController controller, std::function setpointSource, std::function useOutput, wpi::ArrayRef requirements) - : m_controller{controller}, + : m_controller{std::move(controller)}, m_measurement{std::move(measurementSource)}, m_setpoint{std::move(setpointSource)}, m_useOutput{std::move(useOutput)} { diff --git a/wpilibNewCommands/src/main/native/cpp/frc2/command/PIDSubsystem.cpp b/wpilibNewCommands/src/main/native/cpp/frc2/command/PIDSubsystem.cpp index c869776dc7..7c820aef96 100644 --- a/wpilibNewCommands/src/main/native/cpp/frc2/command/PIDSubsystem.cpp +++ b/wpilibNewCommands/src/main/native/cpp/frc2/command/PIDSubsystem.cpp @@ -4,10 +4,12 @@ #include "frc2/command/PIDSubsystem.h" +#include + using namespace frc2; PIDSubsystem::PIDSubsystem(PIDController controller, double initialPosition) - : m_controller{controller} { + : m_controller{std::move(controller)} { SetSetpoint(initialPosition); AddChild("PID Controller", &m_controller); } diff --git a/wpilibNewCommands/src/main/native/cpp/frc2/command/RamseteCommand.cpp b/wpilibNewCommands/src/main/native/cpp/frc2/command/RamseteCommand.cpp index 26c1e06b58..4c6cf73e6c 100644 --- a/wpilibNewCommands/src/main/native/cpp/frc2/command/RamseteCommand.cpp +++ b/wpilibNewCommands/src/main/native/cpp/frc2/command/RamseteCommand.cpp @@ -4,6 +4,8 @@ #include "frc2/command/RamseteCommand.h" +#include + using namespace frc2; using namespace units; @@ -16,15 +18,15 @@ RamseteCommand::RamseteCommand( frc2::PIDController leftController, frc2::PIDController rightController, std::function output, std::initializer_list requirements) - : m_trajectory(trajectory), - m_pose(pose), + : m_trajectory(std::move(trajectory)), + m_pose(std::move(pose)), m_controller(controller), m_feedforward(feedforward), m_kinematics(kinematics), - m_speeds(wheelSpeeds), + m_speeds(std::move(wheelSpeeds)), m_leftController(std::make_unique(leftController)), m_rightController(std::make_unique(rightController)), - m_outputVolts(output), + m_outputVolts(std::move(output)), m_usePID(true) { AddRequirements(requirements); } @@ -38,15 +40,15 @@ RamseteCommand::RamseteCommand( frc2::PIDController leftController, frc2::PIDController rightController, std::function output, wpi::ArrayRef requirements) - : m_trajectory(trajectory), - m_pose(pose), + : m_trajectory(std::move(trajectory)), + m_pose(std::move(pose)), m_controller(controller), m_feedforward(feedforward), m_kinematics(kinematics), - m_speeds(wheelSpeeds), + m_speeds(std::move(wheelSpeeds)), m_leftController(std::make_unique(leftController)), m_rightController(std::make_unique(rightController)), - m_outputVolts(output), + m_outputVolts(std::move(output)), m_usePID(true) { AddRequirements(requirements); } @@ -58,11 +60,11 @@ RamseteCommand::RamseteCommand( std::function output, std::initializer_list requirements) - : m_trajectory(trajectory), - m_pose(pose), + : m_trajectory(std::move(trajectory)), + m_pose(std::move(pose)), m_controller(controller), m_kinematics(kinematics), - m_outputVel(output), + m_outputVel(std::move(output)), m_usePID(false) { AddRequirements(requirements); } @@ -74,11 +76,11 @@ RamseteCommand::RamseteCommand( std::function output, wpi::ArrayRef requirements) - : m_trajectory(trajectory), - m_pose(pose), + : m_trajectory(std::move(trajectory)), + m_pose(std::move(pose)), m_controller(controller), m_kinematics(kinematics), - m_outputVel(output), + m_outputVel(std::move(output)), m_usePID(false) { AddRequirements(requirements); } diff --git a/wpilibNewCommands/src/main/native/include/frc2/command/SelectCommand.h b/wpilibNewCommands/src/main/native/include/frc2/command/SelectCommand.h index 580a439a5f..9710e54fcc 100644 --- a/wpilibNewCommands/src/main/native/include/frc2/command/SelectCommand.h +++ b/wpilibNewCommands/src/main/native/include/frc2/command/SelectCommand.h @@ -99,7 +99,8 @@ class SelectCommand : public CommandHelper> { * * @param toRun a supplier providing the command to run */ - explicit SelectCommand(std::function toRun) : m_toRun{toRun} {} + explicit SelectCommand(std::function toRun) + : m_toRun{std::move(toRun)} {} SelectCommand(SelectCommand&& other) = default; diff --git a/wpilibOldCommands/src/main/native/cpp/commands/InstantCommand.cpp b/wpilibOldCommands/src/main/native/cpp/commands/InstantCommand.cpp index f487c87aa7..ea8f720bf3 100644 --- a/wpilibOldCommands/src/main/native/cpp/commands/InstantCommand.cpp +++ b/wpilibOldCommands/src/main/native/cpp/commands/InstantCommand.cpp @@ -4,6 +4,8 @@ #include "frc/commands/InstantCommand.h" +#include + using namespace frc; InstantCommand::InstantCommand(const wpi::Twine& name) : Command(name) {} @@ -13,7 +15,8 @@ InstantCommand::InstantCommand(Subsystem& subsystem) : Command(subsystem) {} InstantCommand::InstantCommand(const wpi::Twine& name, Subsystem& subsystem) : Command(name, subsystem) {} -InstantCommand::InstantCommand(std::function func) : m_func(func) {} +InstantCommand::InstantCommand(std::function func) + : m_func(std::move(func)) {} InstantCommand::InstantCommand(Subsystem& subsystem, std::function func) : InstantCommand(subsystem) { diff --git a/wpilibc/src/main/native/cpp/AnalogPotentiometer.cpp b/wpilibc/src/main/native/cpp/AnalogPotentiometer.cpp index e16bab4d29..b911285bb1 100644 --- a/wpilibc/src/main/native/cpp/AnalogPotentiometer.cpp +++ b/wpilibc/src/main/native/cpp/AnalogPotentiometer.cpp @@ -4,6 +4,8 @@ #include "frc/AnalogPotentiometer.h" +#include + #include "frc/Base.h" #include "frc/RobotController.h" #include "frc/smartdashboard/SendableBuilder.h" @@ -26,7 +28,9 @@ AnalogPotentiometer::AnalogPotentiometer(AnalogInput* input, double fullRange, AnalogPotentiometer::AnalogPotentiometer(std::shared_ptr input, double fullRange, double offset) - : m_analog_input(input), m_fullRange(fullRange), m_offset(offset) { + : m_analog_input(std::move(input)), + m_fullRange(fullRange), + m_offset(offset) { SendableRegistry::GetInstance().AddLW(this, "AnalogPotentiometer", m_analog_input->GetChannel()); } diff --git a/wpilibc/src/main/native/cpp/Encoder.cpp b/wpilibc/src/main/native/cpp/Encoder.cpp index d469917e6b..107d755362 100644 --- a/wpilibc/src/main/native/cpp/Encoder.cpp +++ b/wpilibc/src/main/native/cpp/Encoder.cpp @@ -48,7 +48,7 @@ Encoder::Encoder(DigitalSource& aSource, DigitalSource& bSource, Encoder::Encoder(std::shared_ptr aSource, std::shared_ptr bSource, bool reverseDirection, EncodingType encodingType) - : m_aSource(aSource), m_bSource(bSource) { + : m_aSource(std::move(aSource)), m_bSource(std::move(bSource)) { if (m_aSource == nullptr || m_bSource == nullptr) { wpi_setWPIError(NullParameter); } else { diff --git a/wpilibc/src/main/native/cpp/Ultrasonic.cpp b/wpilibc/src/main/native/cpp/Ultrasonic.cpp index be2b90170e..dd34fe8553 100644 --- a/wpilibc/src/main/native/cpp/Ultrasonic.cpp +++ b/wpilibc/src/main/native/cpp/Ultrasonic.cpp @@ -4,6 +4,8 @@ #include "frc/Ultrasonic.h" +#include + #include #include "frc/Base.h" @@ -61,8 +63,8 @@ Ultrasonic::Ultrasonic(DigitalOutput& pingChannel, DigitalInput& echoChannel, Ultrasonic::Ultrasonic(std::shared_ptr pingChannel, std::shared_ptr echoChannel, DistanceUnit units) - : m_pingChannel(pingChannel), - m_echoChannel(echoChannel), + : m_pingChannel(std::move(pingChannel)), + m_echoChannel(std::move(echoChannel)), m_counter(m_echoChannel) { m_units = units; Initialize(); diff --git a/wpilibc/src/main/native/cpp/Watchdog.cpp b/wpilibc/src/main/native/cpp/Watchdog.cpp index bf1026def0..e93457f33f 100644 --- a/wpilibc/src/main/native/cpp/Watchdog.cpp +++ b/wpilibc/src/main/native/cpp/Watchdog.cpp @@ -5,6 +5,7 @@ #include "frc/Watchdog.h" #include +#include #include #include @@ -137,7 +138,7 @@ Watchdog::Watchdog(double timeout, std::function callback) : Watchdog(units::second_t{timeout}, callback) {} Watchdog::Watchdog(units::second_t timeout, std::function callback) - : m_timeout(timeout), m_callback(callback), m_impl(GetImpl()) {} + : m_timeout(timeout), m_callback(std::move(callback)), m_impl(GetImpl()) {} Watchdog::~Watchdog() { Disable(); diff --git a/wpilibc/src/main/native/cpp/controller/HolonomicDriveController.cpp b/wpilibc/src/main/native/cpp/controller/HolonomicDriveController.cpp index fc0cf93e9a..87a436c106 100644 --- a/wpilibc/src/main/native/cpp/controller/HolonomicDriveController.cpp +++ b/wpilibc/src/main/native/cpp/controller/HolonomicDriveController.cpp @@ -4,17 +4,18 @@ #include "frc/controller/HolonomicDriveController.h" +#include + #include using namespace frc; HolonomicDriveController::HolonomicDriveController( - const frc2::PIDController& xController, - const frc2::PIDController& yController, - const ProfiledPIDController& thetaController) - : m_xController(xController), - m_yController(yController), - m_thetaController(thetaController) {} + frc2::PIDController xController, frc2::PIDController yController, + ProfiledPIDController thetaController) + : m_xController(std::move(xController)), + m_yController(std::move(yController)), + m_thetaController(std::move(thetaController)) {} bool HolonomicDriveController::AtReference() const { const auto& eTranslate = m_poseError.Translation(); diff --git a/wpilibc/src/main/native/cpp/simulation/CallbackStore.cpp b/wpilibc/src/main/native/cpp/simulation/CallbackStore.cpp index 54f7057eef..be071e94e2 100644 --- a/wpilibc/src/main/native/cpp/simulation/CallbackStore.cpp +++ b/wpilibc/src/main/native/cpp/simulation/CallbackStore.cpp @@ -4,6 +4,8 @@ #include "frc/simulation/CallbackStore.h" +#include + using namespace frc; using namespace frc::sim; @@ -21,31 +23,35 @@ void frc::sim::ConstBufferCallbackStoreThunk(const char* name, void* param, CallbackStore::CallbackStore(int32_t i, NotifyCallback cb, CancelCallbackNoIndexFunc ccf) - : index(i), callback(cb), cancelType(NoIndex) { + : index(i), callback(std::move(cb)), cancelType(NoIndex) { this->ccnif = ccf; } CallbackStore::CallbackStore(int32_t i, int32_t u, NotifyCallback cb, CancelCallbackFunc ccf) - : index(i), uid(u), callback(cb), cancelType(Normal) { + : index(i), uid(u), callback(std::move(cb)), cancelType(Normal) { this->ccf = ccf; } CallbackStore::CallbackStore(int32_t i, int32_t c, int32_t u, NotifyCallback cb, CancelCallbackChannelFunc ccf) - : index(i), channel(c), uid(u), callback(cb), cancelType(Channel) { + : index(i), + channel(c), + uid(u), + callback(std::move(cb)), + cancelType(Channel) { this->cccf = ccf; } CallbackStore::CallbackStore(int32_t i, ConstBufferCallback cb, CancelCallbackNoIndexFunc ccf) - : index(i), constBufferCallback(cb), cancelType(NoIndex) { + : index(i), constBufferCallback(std::move(cb)), cancelType(NoIndex) { this->ccnif = ccf; } CallbackStore::CallbackStore(int32_t i, int32_t u, ConstBufferCallback cb, CancelCallbackFunc ccf) - : index(i), uid(u), constBufferCallback(cb), cancelType(Normal) { + : index(i), uid(u), constBufferCallback(std::move(cb)), cancelType(Normal) { this->ccf = ccf; } @@ -55,7 +61,7 @@ CallbackStore::CallbackStore(int32_t i, int32_t c, int32_t u, : index(i), channel(c), uid(u), - constBufferCallback(cb), + constBufferCallback(std::move(cb)), cancelType(Channel) { this->cccf = ccf; } diff --git a/wpilibc/src/main/native/cpp/simulation/DifferentialDrivetrainSim.cpp b/wpilibc/src/main/native/cpp/simulation/DifferentialDrivetrainSim.cpp index c11f34845f..f4330f4121 100644 --- a/wpilibc/src/main/native/cpp/simulation/DifferentialDrivetrainSim.cpp +++ b/wpilibc/src/main/native/cpp/simulation/DifferentialDrivetrainSim.cpp @@ -6,6 +6,8 @@ #include +#include + #include "frc/RobotController.h" #include "frc/system/RungeKutta.h" @@ -13,10 +15,10 @@ using namespace frc; using namespace frc::sim; DifferentialDrivetrainSim::DifferentialDrivetrainSim( - const LinearSystem<2, 2, 2>& plant, units::meter_t trackWidth, - DCMotor driveMotor, double gearRatio, units::meter_t wheelRadius, + LinearSystem<2, 2, 2> plant, units::meter_t trackWidth, DCMotor driveMotor, + double gearRatio, units::meter_t wheelRadius, const std::array& measurementStdDevs) - : m_plant(plant), + : m_plant(std::move(plant)), m_rb(trackWidth / 2.0), m_wheelRadius(wheelRadius), m_motor(driveMotor), diff --git a/wpilibc/src/main/native/include/frc/TimedRobot.h b/wpilibc/src/main/native/include/frc/TimedRobot.h index d739274d18..817e6317b3 100644 --- a/wpilibc/src/main/native/include/frc/TimedRobot.h +++ b/wpilibc/src/main/native/include/frc/TimedRobot.h @@ -5,6 +5,7 @@ #pragma once #include +#include #include #include @@ -102,7 +103,7 @@ class TimedRobot : public IterativeRobotBase, public ErrorBase { */ Callback(std::function func, units::second_t startTime, units::second_t period, units::second_t offset) - : func{func}, + : func{std::move(func)}, period{period}, expirationTime{ startTime + offset + diff --git a/wpilibc/src/main/native/include/frc/controller/HolonomicDriveController.h b/wpilibc/src/main/native/include/frc/controller/HolonomicDriveController.h index 0b9d6c4361..6713f75fe1 100644 --- a/wpilibc/src/main/native/include/frc/controller/HolonomicDriveController.h +++ b/wpilibc/src/main/native/include/frc/controller/HolonomicDriveController.h @@ -41,9 +41,8 @@ class HolonomicDriveController { * angle. */ HolonomicDriveController( - const frc2::PIDController& xController, - const frc2::PIDController& yController, - const ProfiledPIDController& thetaController); + frc2::PIDController xController, frc2::PIDController yController, + ProfiledPIDController thetaController); /** * Returns true if the pose error is within tolerance of the reference. diff --git a/wpilibc/src/main/native/include/frc/simulation/DifferentialDrivetrainSim.h b/wpilibc/src/main/native/include/frc/simulation/DifferentialDrivetrainSim.h index 30b5ce4f58..e67445d08a 100644 --- a/wpilibc/src/main/native/include/frc/simulation/DifferentialDrivetrainSim.h +++ b/wpilibc/src/main/native/include/frc/simulation/DifferentialDrivetrainSim.h @@ -41,7 +41,7 @@ class DifferentialDrivetrainSim { * starting point. */ DifferentialDrivetrainSim( - const LinearSystem<2, 2, 2>& plant, units::meter_t trackWidth, + LinearSystem<2, 2, 2> plant, units::meter_t trackWidth, DCMotor driveMotor, double gearingRatio, units::meter_t wheelRadius, const std::array& measurementStdDevs = {}); diff --git a/wpilibcExamples/src/main/cpp/examples/GearsBot/cpp/commands/TankDrive.cpp b/wpilibcExamples/src/main/cpp/examples/GearsBot/cpp/commands/TankDrive.cpp index 663e3470d0..3d905c30bc 100644 --- a/wpilibcExamples/src/main/cpp/examples/GearsBot/cpp/commands/TankDrive.cpp +++ b/wpilibcExamples/src/main/cpp/examples/GearsBot/cpp/commands/TankDrive.cpp @@ -4,11 +4,15 @@ #include "commands/TankDrive.h" +#include + #include "Robot.h" TankDrive::TankDrive(std::function left, std::function right, DriveTrain* drivetrain) - : m_left(left), m_right(right), m_drivetrain(drivetrain) { + : m_left(std::move(left)), + m_right(std::move(right)), + m_drivetrain(drivetrain) { SetName("TankDrive"); AddRequirements({m_drivetrain}); } diff --git a/wpilibcExamples/src/main/cpp/examples/HatchbotTraditional/cpp/commands/DefaultDrive.cpp b/wpilibcExamples/src/main/cpp/examples/HatchbotTraditional/cpp/commands/DefaultDrive.cpp index 065c1b1a73..7ef404eb56 100644 --- a/wpilibcExamples/src/main/cpp/examples/HatchbotTraditional/cpp/commands/DefaultDrive.cpp +++ b/wpilibcExamples/src/main/cpp/examples/HatchbotTraditional/cpp/commands/DefaultDrive.cpp @@ -4,10 +4,14 @@ #include "commands/DefaultDrive.h" +#include + DefaultDrive::DefaultDrive(DriveSubsystem* subsystem, std::function forward, std::function rotation) - : m_drive{subsystem}, m_forward{forward}, m_rotation{rotation} { + : m_drive{subsystem}, + m_forward{std::move(forward)}, + m_rotation{std::move(rotation)} { AddRequirements({subsystem}); } diff --git a/wpiutil/src/main/native/cpp/WebSocketServer.cpp b/wpiutil/src/main/native/cpp/WebSocketServer.cpp index 956489c438..637ceff104 100644 --- a/wpiutil/src/main/native/cpp/WebSocketServer.cpp +++ b/wpiutil/src/main/native/cpp/WebSocketServer.cpp @@ -4,6 +4,8 @@ #include "wpi/WebSocketServer.h" +#include + #include "wpi/raw_uv_ostream.h" #include "wpi/uv/Buffer.h" #include "wpi/uv/Stream.h" @@ -58,12 +60,11 @@ std::pair WebSocketServerHelper::MatchProtocol( WebSocketServer::WebSocketServer(uv::Stream& stream, ArrayRef protocols, - const ServerOptions& options, - const private_init&) + ServerOptions options, const private_init&) : m_stream{stream}, m_helper{m_req}, m_protocols{protocols.begin(), protocols.end()}, - m_options{options} { + m_options{std::move(options)} { // Header handling m_req.header.connect([this](StringRef name, StringRef value) { if (name.equals_lower("host")) { diff --git a/wpiutil/src/main/native/include/wpi/Logger.h b/wpiutil/src/main/native/include/wpi/Logger.h index 512b9e069a..5ee14f506e 100644 --- a/wpiutil/src/main/native/include/wpi/Logger.h +++ b/wpiutil/src/main/native/include/wpi/Logger.h @@ -6,6 +6,7 @@ #define WPIUTIL_WPI_LOGGER_H_ #include +#include #include "wpi/SmallString.h" #include "wpi/raw_ostream.h" @@ -30,9 +31,9 @@ class Logger { unsigned int line, const char* msg)>; Logger() = default; - explicit Logger(const LogFunc& func) : m_func(func) {} - Logger(const LogFunc& func, unsigned int min_level) - : m_func(func), m_min_level(min_level) {} + explicit Logger(LogFunc func) : m_func(std::move(func)) {} + Logger(LogFunc func, unsigned int min_level) + : m_func(std::move(func)), m_min_level(min_level) {} void SetLogger(LogFunc func) { m_func = func; } diff --git a/wpiutil/src/main/native/include/wpi/WebSocketServer.h b/wpiutil/src/main/native/include/wpi/WebSocketServer.h index 979b8e2ae4..f911cb438f 100644 --- a/wpiutil/src/main/native/include/wpi/WebSocketServer.h +++ b/wpiutil/src/main/native/include/wpi/WebSocketServer.h @@ -122,7 +122,7 @@ class WebSocketServer : public std::enable_shared_from_this { * Private constructor. */ WebSocketServer(uv::Stream& stream, ArrayRef protocols, - const ServerOptions& options, const private_init&); + ServerOptions options, const private_init&); /** * Starts a dedicated WebSocket server on the provided connection. The diff --git a/wpiutil/src/main/native/include/wpi/raw_uv_ostream.h b/wpiutil/src/main/native/include/wpi/raw_uv_ostream.h index f46916daa2..ba6ad51e1d 100644 --- a/wpiutil/src/main/native/include/wpi/raw_uv_ostream.h +++ b/wpiutil/src/main/native/include/wpi/raw_uv_ostream.h @@ -5,6 +5,8 @@ #ifndef WPIUTIL_WPI_RAW_UV_OSTREAM_H_ #define WPIUTIL_WPI_RAW_UV_OSTREAM_H_ +#include + #include "wpi/ArrayRef.h" #include "wpi/SmallVector.h" #include "wpi/raw_ostream.h" @@ -38,7 +40,7 @@ class raw_uv_ostream : public raw_ostream { */ raw_uv_ostream(SmallVectorImpl& bufs, std::function alloc) - : m_bufs(bufs), m_alloc(alloc) { + : m_bufs(bufs), m_alloc(std::move(alloc)) { SetUnbuffered(); }