Add move constructors and assignment operators to wpilibc (#1314)

Fixes #898.
This commit is contained in:
Tyler Veness
2018-09-24 00:08:25 -07:00
committed by Peter Johnson
parent b1965f74a8
commit 1aa8446725
136 changed files with 764 additions and 89 deletions

View File

@@ -7,6 +7,8 @@
#include "frc/DoubleSolenoid.h"
#include <utility>
#include <hal/HAL.h>
#include <hal/Ports.h>
#include <hal/Solenoid.h>
@@ -81,6 +83,29 @@ DoubleSolenoid::~DoubleSolenoid() {
HAL_FreeSolenoidPort(m_reverseHandle);
}
DoubleSolenoid::DoubleSolenoid(DoubleSolenoid&& rhs)
: SolenoidBase(std::move(rhs)),
m_forwardChannel(std::move(rhs.m_forwardChannel)),
m_reverseChannel(std::move(rhs.m_reverseChannel)),
m_forwardMask(std::move(rhs.m_forwardMask)),
m_reverseMask(std::move(rhs.m_reverseMask)) {
std::swap(m_forwardHandle, rhs.m_forwardHandle);
std::swap(m_reverseHandle, rhs.m_reverseHandle);
}
DoubleSolenoid& DoubleSolenoid::operator=(DoubleSolenoid&& rhs) {
SolenoidBase::operator=(std::move(rhs));
m_forwardChannel = std::move(rhs.m_forwardChannel);
m_reverseChannel = std::move(rhs.m_reverseChannel);
m_forwardMask = std::move(rhs.m_forwardMask);
m_reverseMask = std::move(rhs.m_reverseMask);
std::swap(m_forwardHandle, rhs.m_forwardHandle);
std::swap(m_reverseHandle, rhs.m_reverseHandle);
return *this;
}
void DoubleSolenoid::Set(Value value) {
if (StatusIsFatal()) return;