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

@@ -8,6 +8,7 @@
#include "frc/AnalogOutput.h"
#include <limits>
#include <utility>
#include <hal/HAL.h>
#include <hal/Ports.h>
@@ -46,6 +47,23 @@ AnalogOutput::AnalogOutput(int channel) {
AnalogOutput::~AnalogOutput() { HAL_FreeAnalogOutputPort(m_port); }
AnalogOutput::AnalogOutput(AnalogOutput&& rhs)
: ErrorBase(std::move(rhs)),
SendableBase(std::move(rhs)),
m_channel(std::move(rhs.m_channel)) {
std::swap(m_port, rhs.m_port);
}
AnalogOutput& AnalogOutput::operator=(AnalogOutput&& rhs) {
ErrorBase::operator=(std::move(rhs));
SendableBase::operator=(std::move(rhs));
m_channel = std::move(rhs.m_channel);
std::swap(m_port, rhs.m_port);
return *this;
}
void AnalogOutput::SetVoltage(double voltage) {
int32_t status = 0;
HAL_SetAnalogOutput(m_port, voltage, &status);