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/PWM.h"
#include <utility>
#include <hal/HAL.h>
#include <hal/PWM.h>
#include <hal/Ports.h>
@@ -57,6 +59,23 @@ PWM::~PWM() {
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
}
PWM::PWM(PWM&& rhs)
: ErrorBase(std::move(rhs)),
SendableBase(std::move(rhs)),
m_channel(std::move(rhs.m_channel)) {
std::swap(m_handle, rhs.m_handle);
}
PWM& PWM::operator=(PWM&& 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);
return *this;
}
void PWM::SetRaw(uint16_t value) {
if (StatusIsFatal()) return;