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/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));