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,7 +7,7 @@
|
||||
|
||||
#include "frc/AnalogTrigger.h"
|
||||
|
||||
#include <memory>
|
||||
#include <utility>
|
||||
|
||||
#include <hal/HAL.h>
|
||||
|
||||
@@ -43,11 +43,32 @@ AnalogTrigger::~AnalogTrigger() {
|
||||
int32_t status = 0;
|
||||
HAL_CleanAnalogTrigger(m_trigger, &status);
|
||||
|
||||
if (m_ownsAnalog && m_analogInput != nullptr) {
|
||||
if (m_ownsAnalog) {
|
||||
delete m_analogInput;
|
||||
}
|
||||
}
|
||||
|
||||
AnalogTrigger::AnalogTrigger(AnalogTrigger&& rhs)
|
||||
: ErrorBase(std::move(rhs)),
|
||||
SendableBase(std::move(rhs)),
|
||||
m_index(std::move(rhs.m_index)) {
|
||||
std::swap(m_trigger, rhs.m_trigger);
|
||||
std::swap(m_analogInput, rhs.m_analogInput);
|
||||
std::swap(m_ownsAnalog, rhs.m_ownsAnalog);
|
||||
}
|
||||
|
||||
AnalogTrigger& AnalogTrigger::operator=(AnalogTrigger&& rhs) {
|
||||
ErrorBase::operator=(std::move(rhs));
|
||||
SendableBase::operator=(std::move(rhs));
|
||||
|
||||
m_index = std::move(rhs.m_index);
|
||||
std::swap(m_trigger, rhs.m_trigger);
|
||||
std::swap(m_analogInput, rhs.m_analogInput);
|
||||
std::swap(m_ownsAnalog, rhs.m_ownsAnalog);
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
void AnalogTrigger::SetLimitsVoltage(double lower, double upper) {
|
||||
if (StatusIsFatal()) return;
|
||||
int32_t status = 0;
|
||||
|
||||
Reference in New Issue
Block a user