mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-19 00:41:43 +00:00
Add move constructors and assignment operators to wpilibc (#1314)
Fixes #898.
This commit is contained in:
committed by
Peter Johnson
parent
b1965f74a8
commit
1aa8446725
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user