mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-19 00:41:43 +00:00
Add move constructors and assignment operators to wpilibc (#1314)
Fixes #898.
This commit is contained in:
committed by
Peter Johnson
parent
b1965f74a8
commit
1aa8446725
@@ -7,6 +7,8 @@
|
||||
|
||||
#include "frc/Relay.h"
|
||||
|
||||
#include <utility>
|
||||
|
||||
#include <hal/HAL.h>
|
||||
#include <hal/Ports.h>
|
||||
#include <hal/Relay.h>
|
||||
@@ -90,6 +92,31 @@ Relay::~Relay() {
|
||||
if (m_reverseHandle != HAL_kInvalidHandle) HAL_FreeRelayPort(m_reverseHandle);
|
||||
}
|
||||
|
||||
Relay::Relay(Relay&& rhs)
|
||||
: MotorSafety(std::move(rhs)),
|
||||
ErrorBase(std::move(rhs)),
|
||||
SendableBase(std::move(rhs)),
|
||||
m_channel(std::move(rhs.m_channel)),
|
||||
m_direction(std::move(rhs.m_direction)),
|
||||
m_safetyHelper(std::move(rhs.m_safetyHelper)) {
|
||||
std::swap(m_forwardHandle, rhs.m_forwardHandle);
|
||||
std::swap(m_reverseHandle, rhs.m_reverseHandle);
|
||||
}
|
||||
|
||||
Relay& Relay::operator=(Relay&& rhs) {
|
||||
MotorSafety::operator=(std::move(rhs));
|
||||
ErrorBase::operator=(std::move(rhs));
|
||||
SendableBase::operator=(std::move(rhs));
|
||||
|
||||
m_channel = std::move(rhs.m_channel);
|
||||
m_direction = std::move(rhs.m_direction);
|
||||
std::swap(m_forwardHandle, rhs.m_forwardHandle);
|
||||
std::swap(m_reverseHandle, rhs.m_reverseHandle);
|
||||
m_safetyHelper = std::move(rhs.m_safetyHelper);
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
void Relay::Set(Relay::Value value) {
|
||||
if (StatusIsFatal()) return;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user