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/Counter.h"
|
||||
|
||||
#include <utility>
|
||||
|
||||
#include <hal/HAL.h>
|
||||
|
||||
#include "frc/AnalogTrigger.h"
|
||||
@@ -91,6 +93,29 @@ Counter::~Counter() {
|
||||
m_counter = HAL_kInvalidHandle;
|
||||
}
|
||||
|
||||
Counter::Counter(Counter&& rhs)
|
||||
: ErrorBase(std::move(rhs)),
|
||||
SendableBase(std::move(rhs)),
|
||||
CounterBase(std::move(rhs)),
|
||||
m_upSource(std::move(rhs.m_upSource)),
|
||||
m_downSource(std::move(rhs.m_downSource)),
|
||||
m_index(std::move(rhs.m_index)) {
|
||||
std::swap(m_counter, rhs.m_counter);
|
||||
}
|
||||
|
||||
Counter& Counter::operator=(Counter&& rhs) {
|
||||
ErrorBase::operator=(std::move(rhs));
|
||||
SendableBase::operator=(std::move(rhs));
|
||||
CounterBase::operator=(std::move(rhs));
|
||||
|
||||
m_upSource = std::move(rhs.m_upSource);
|
||||
m_downSource = std::move(rhs.m_downSource);
|
||||
std::swap(m_counter, rhs.m_counter);
|
||||
m_index = std::move(rhs.m_index);
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
void Counter::SetUpSource(int channel) {
|
||||
if (StatusIsFatal()) return;
|
||||
SetUpSource(std::make_shared<DigitalInput>(channel));
|
||||
|
||||
Reference in New Issue
Block a user