clang-tidy: modernize-pass-by-value

This commit is contained in:
Peter Johnson
2020-12-28 10:12:52 -08:00
parent 29c7da5f1a
commit aee4603269
32 changed files with 158 additions and 107 deletions

View File

@@ -23,7 +23,7 @@ namespace cs {
struct SourceData {
SourceData(CS_SourceKind kind_, std::shared_ptr<SourceImpl> 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<SinkImpl> 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;

View File

@@ -5,6 +5,7 @@
#include "Notifier.h"
#include <queue>
#include <utility>
#include <vector>
#include "Handle.h"
@@ -66,7 +67,7 @@ class UidVector {
class Notifier::Thread : public wpi::SafeThread {
public:
Thread(std::function<void()> on_start, std::function<void()> 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<void(const RawEvent& event)> callback_,
int eventMask_)
: callback(callback_), eventMask(eventMask_) {}
: callback(std::move(callback_)), eventMask(eventMask_) {}
explicit operator bool() const { return static_cast<bool>(callback); }

View File

@@ -4,6 +4,8 @@
#include "NetworkConnection.h"
#include <utility>
#include <wpi/NetworkStream.h>
#include <wpi/raw_socket_istream.h>
#include <wpi/timestamp.h>
@@ -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;

View File

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

View File

@@ -4,6 +4,7 @@
#include <cctype>
#include <string>
#include <utility>
#include <wpi/Base64.h>
#include <wpi/SmallString.h>
@@ -24,7 +25,7 @@ class LoadPersistentImpl {
using WarnFunc = std::function<void(size_t, const char*)>;
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<Entry>* entries);

View File

@@ -104,7 +104,7 @@ struct ConnectionInfo {
struct RpcParamDef {
RpcParamDef() = default;
RpcParamDef(StringRef name_, std::shared_ptr<Value> def_value_)
: name(name_), def_value(def_value_) {}
: name(name_), def_value(std::move(def_value_)) {}
std::string name;
std::shared_ptr<Value> 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};

View File

@@ -7,6 +7,7 @@
#include <memory>
#include <ostream>
#include <utility>
#include "Message.h"
#include "TestPrinters.h"
@@ -18,7 +19,7 @@ class MessageMatcher
: public ::testing::MatcherInterface<std::shared_ptr<Message>> {
public:
explicit MessageMatcher(std::shared_ptr<Message> goodmsg_)
: goodmsg(goodmsg_) {}
: goodmsg(std::move(goodmsg_)) {}
bool MatchAndExplain(std::shared_ptr<Message> msg,
::testing::MatchResultListener* listener) const override;

View File

@@ -7,6 +7,7 @@
#include <memory>
#include <ostream>
#include <utility>
#include "gmock/gmock.h"
#include "networktables/NetworkTableValue.h"
@@ -16,7 +17,8 @@ namespace nt {
class ValueMatcher
: public ::testing::MatcherInterface<std::shared_ptr<Value>> {
public:
explicit ValueMatcher(std::shared_ptr<Value> goodval_) : goodval(goodval_) {}
explicit ValueMatcher(std::shared_ptr<Value> goodval_)
: goodval(std::move(goodval_)) {}
bool MatchAndExplain(std::shared_ptr<Value> msg,
::testing::MatchResultListener* listener) const override;

View File

@@ -4,11 +4,12 @@
#include "WSBaseProvider.h"
#include <utility>
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

View File

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

View File

@@ -4,6 +4,8 @@
#include "frc2/command/MecanumControllerCommand.h"
#include <utility>
using namespace frc2;
using namespace units;
@@ -24,12 +26,12 @@ MecanumControllerCommand::MecanumControllerCommand(
units::volt_t)>
output,
std::initializer_list<Subsystem*> 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<frc2::PIDController>(frontLeftController)),
@@ -39,8 +41,8 @@ MecanumControllerCommand::MecanumControllerCommand(
std::make_unique<frc2::PIDController>(frontRightController)),
m_rearRightController(
std::make_unique<frc2::PIDController>(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<Subsystem*> 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<frc2::PIDController>(frontRightController)),
m_rearRightController(
std::make_unique<frc2::PIDController>(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<Subsystem*> 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<frc2::PIDController>(frontLeftController)),
@@ -116,8 +118,8 @@ MecanumControllerCommand::MecanumControllerCommand(
std::make_unique<frc2::PIDController>(frontRightController)),
m_rearRightController(
std::make_unique<frc2::PIDController>(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<Subsystem*> 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<frc2::PIDController>(frontRightController)),
m_rearRightController(
std::make_unique<frc2::PIDController>(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<Subsystem*> 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<Subsystem*> 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<Subsystem*> 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<Subsystem*> 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 = [&] {

View File

@@ -4,6 +4,8 @@
#include "frc2/command/PIDCommand.h"
#include <utility>
using namespace frc2;
PIDCommand::PIDCommand(PIDController controller,
@@ -11,7 +13,7 @@ PIDCommand::PIDCommand(PIDController controller,
std::function<double()> setpointSource,
std::function<void(double)> useOutput,
std::initializer_list<Subsystem*> 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<double()> setpointSource,
std::function<void(double)> useOutput,
wpi::ArrayRef<Subsystem*> requirements)
: m_controller{controller},
: m_controller{std::move(controller)},
m_measurement{std::move(measurementSource)},
m_setpoint{std::move(setpointSource)},
m_useOutput{std::move(useOutput)} {

View File

@@ -4,10 +4,12 @@
#include "frc2/command/PIDSubsystem.h"
#include <utility>
using namespace frc2;
PIDSubsystem::PIDSubsystem(PIDController controller, double initialPosition)
: m_controller{controller} {
: m_controller{std::move(controller)} {
SetSetpoint(initialPosition);
AddChild("PID Controller", &m_controller);
}

View File

@@ -4,6 +4,8 @@
#include "frc2/command/RamseteCommand.h"
#include <utility>
using namespace frc2;
using namespace units;
@@ -16,15 +18,15 @@ RamseteCommand::RamseteCommand(
frc2::PIDController leftController, frc2::PIDController rightController,
std::function<void(volt_t, volt_t)> output,
std::initializer_list<Subsystem*> 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<frc2::PIDController>(leftController)),
m_rightController(std::make_unique<frc2::PIDController>(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<void(volt_t, volt_t)> output,
wpi::ArrayRef<Subsystem*> 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<frc2::PIDController>(leftController)),
m_rightController(std::make_unique<frc2::PIDController>(rightController)),
m_outputVolts(output),
m_outputVolts(std::move(output)),
m_usePID(true) {
AddRequirements(requirements);
}
@@ -58,11 +60,11 @@ RamseteCommand::RamseteCommand(
std::function<void(units::meters_per_second_t, units::meters_per_second_t)>
output,
std::initializer_list<Subsystem*> 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<void(units::meters_per_second_t, units::meters_per_second_t)>
output,
wpi::ArrayRef<Subsystem*> 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);
}

View File

@@ -99,7 +99,8 @@ class SelectCommand : public CommandHelper<CommandBase, SelectCommand<Key>> {
*
* @param toRun a supplier providing the command to run
*/
explicit SelectCommand(std::function<Command*()> toRun) : m_toRun{toRun} {}
explicit SelectCommand(std::function<Command*()> toRun)
: m_toRun{std::move(toRun)} {}
SelectCommand(SelectCommand&& other) = default;

View File

@@ -4,6 +4,8 @@
#include "frc/commands/InstantCommand.h"
#include <utility>
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<void()> func) : m_func(func) {}
InstantCommand::InstantCommand(std::function<void()> func)
: m_func(std::move(func)) {}
InstantCommand::InstantCommand(Subsystem& subsystem, std::function<void()> func)
: InstantCommand(subsystem) {

View File

@@ -4,6 +4,8 @@
#include "frc/AnalogPotentiometer.h"
#include <utility>
#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<AnalogInput> 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());
}

View File

@@ -48,7 +48,7 @@ Encoder::Encoder(DigitalSource& aSource, DigitalSource& bSource,
Encoder::Encoder(std::shared_ptr<DigitalSource> aSource,
std::shared_ptr<DigitalSource> 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 {

View File

@@ -4,6 +4,8 @@
#include "frc/Ultrasonic.h"
#include <utility>
#include <hal/FRCUsageReporting.h>
#include "frc/Base.h"
@@ -61,8 +63,8 @@ Ultrasonic::Ultrasonic(DigitalOutput& pingChannel, DigitalInput& echoChannel,
Ultrasonic::Ultrasonic(std::shared_ptr<DigitalOutput> pingChannel,
std::shared_ptr<DigitalInput> 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();

View File

@@ -5,6 +5,7 @@
#include "frc/Watchdog.h"
#include <atomic>
#include <utility>
#include <hal/Notifier.h>
#include <wpi/Format.h>
@@ -137,7 +138,7 @@ Watchdog::Watchdog(double timeout, std::function<void()> callback)
: Watchdog(units::second_t{timeout}, callback) {}
Watchdog::Watchdog(units::second_t timeout, std::function<void()> callback)
: m_timeout(timeout), m_callback(callback), m_impl(GetImpl()) {}
: m_timeout(timeout), m_callback(std::move(callback)), m_impl(GetImpl()) {}
Watchdog::~Watchdog() {
Disable();

View File

@@ -4,17 +4,18 @@
#include "frc/controller/HolonomicDriveController.h"
#include <utility>
#include <units/angular_velocity.h>
using namespace frc;
HolonomicDriveController::HolonomicDriveController(
const frc2::PIDController& xController,
const frc2::PIDController& yController,
const ProfiledPIDController<units::radian>& thetaController)
: m_xController(xController),
m_yController(yController),
m_thetaController(thetaController) {}
frc2::PIDController xController, frc2::PIDController yController,
ProfiledPIDController<units::radian> 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();

View File

@@ -4,6 +4,8 @@
#include "frc/simulation/CallbackStore.h"
#include <utility>
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;
}

View File

@@ -6,6 +6,8 @@
#include <frc/system/plant/LinearSystemId.h>
#include <utility>
#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<double, 7>& measurementStdDevs)
: m_plant(plant),
: m_plant(std::move(plant)),
m_rb(trackWidth / 2.0),
m_wheelRadius(wheelRadius),
m_motor(driveMotor),

View File

@@ -5,6 +5,7 @@
#pragma once
#include <functional>
#include <utility>
#include <vector>
#include <hal/Types.h>
@@ -102,7 +103,7 @@ class TimedRobot : public IterativeRobotBase, public ErrorBase {
*/
Callback(std::function<void()> func, units::second_t startTime,
units::second_t period, units::second_t offset)
: func{func},
: func{std::move(func)},
period{period},
expirationTime{
startTime + offset +

View File

@@ -41,9 +41,8 @@ class HolonomicDriveController {
* angle.
*/
HolonomicDriveController(
const frc2::PIDController& xController,
const frc2::PIDController& yController,
const ProfiledPIDController<units::radian>& thetaController);
frc2::PIDController xController, frc2::PIDController yController,
ProfiledPIDController<units::radian> thetaController);
/**
* Returns true if the pose error is within tolerance of the reference.

View File

@@ -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<double, 7>& measurementStdDevs = {});

View File

@@ -4,11 +4,15 @@
#include "commands/TankDrive.h"
#include <utility>
#include "Robot.h"
TankDrive::TankDrive(std::function<double()> left,
std::function<double()> 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});
}

View File

@@ -4,10 +4,14 @@
#include "commands/DefaultDrive.h"
#include <utility>
DefaultDrive::DefaultDrive(DriveSubsystem* subsystem,
std::function<double()> forward,
std::function<double()> 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});
}

View File

@@ -4,6 +4,8 @@
#include "wpi/WebSocketServer.h"
#include <utility>
#include "wpi/raw_uv_ostream.h"
#include "wpi/uv/Buffer.h"
#include "wpi/uv/Stream.h"
@@ -58,12 +60,11 @@ std::pair<bool, StringRef> WebSocketServerHelper::MatchProtocol(
WebSocketServer::WebSocketServer(uv::Stream& stream,
ArrayRef<StringRef> 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")) {

View File

@@ -6,6 +6,7 @@
#define WPIUTIL_WPI_LOGGER_H_
#include <functional>
#include <utility>
#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; }

View File

@@ -122,7 +122,7 @@ class WebSocketServer : public std::enable_shared_from_this<WebSocketServer> {
* Private constructor.
*/
WebSocketServer(uv::Stream& stream, ArrayRef<StringRef> protocols,
const ServerOptions& options, const private_init&);
ServerOptions options, const private_init&);
/**
* Starts a dedicated WebSocket server on the provided connection. The

View File

@@ -5,6 +5,8 @@
#ifndef WPIUTIL_WPI_RAW_UV_OSTREAM_H_
#define WPIUTIL_WPI_RAW_UV_OSTREAM_H_
#include <utility>
#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<uv::Buffer>& bufs,
std::function<uv::Buffer()> alloc)
: m_bufs(bufs), m_alloc(alloc) {
: m_bufs(bufs), m_alloc(std::move(alloc)) {
SetUnbuffered();
}