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/DigitalOutput.h"
#include <limits>
#include <utility>
#include <hal/DIO.h>
#include <hal/HAL.h>
@@ -51,6 +52,25 @@ DigitalOutput::~DigitalOutput() {
HAL_FreeDIOPort(m_handle);
}
DigitalOutput::DigitalOutput(DigitalOutput&& rhs)
: ErrorBase(std::move(rhs)),
SendableBase(std::move(rhs)),
m_channel(std::move(rhs.m_channel)),
m_pwmGenerator(std::move(rhs.m_pwmGenerator)) {
std::swap(m_handle, rhs.m_handle);
}
DigitalOutput& DigitalOutput::operator=(DigitalOutput&& rhs) {
ErrorBase::operator=(std::move(rhs));
SendableBase::operator=(std::move(rhs));
m_channel = std::move(rhs.m_channel);
std::swap(m_handle, rhs.m_handle);
m_pwmGenerator = std::move(rhs.m_pwmGenerator);
return *this;
}
void DigitalOutput::Set(bool value) {
if (StatusIsFatal()) return;