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/Encoder.h"
#include <utility>
#include <hal/HAL.h>
#include "frc/DigitalInput.h"
@@ -57,6 +59,31 @@ Encoder::~Encoder() {
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
}
Encoder::Encoder(Encoder&& rhs)
: ErrorBase(std::move(rhs)),
SendableBase(std::move(rhs)),
CounterBase(std::move(rhs)),
PIDSource(std::move(rhs)),
m_aSource(std::move(rhs.m_aSource)),
m_bSource(std::move(rhs.m_bSource)),
m_indexSource(std::move(rhs.m_indexSource)) {
std::swap(m_encoder, rhs.m_encoder);
}
Encoder& Encoder::operator=(Encoder&& rhs) {
ErrorBase::operator=(std::move(rhs));
SendableBase::operator=(std::move(rhs));
CounterBase::operator=(std::move(rhs));
PIDSource::operator=(std::move(rhs));
m_aSource = std::move(rhs.m_aSource);
m_bSource = std::move(rhs.m_bSource);
m_indexSource = std::move(rhs.m_indexSource);
std::swap(m_encoder, rhs.m_encoder);
return *this;
}
int Encoder::Get() const {
if (StatusIsFatal()) return 0;
int32_t status = 0;