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

@@ -8,6 +8,7 @@
#include "frc/DigitalInput.h"
#include <limits>
#include <utility>
#include <hal/DIO.h>
#include <hal/HAL.h>
@@ -54,6 +55,20 @@ DigitalInput::~DigitalInput() {
HAL_FreeDIOPort(m_handle);
}
DigitalInput::DigitalInput(DigitalInput&& rhs)
: DigitalSource(std::move(rhs)), m_channel(std::move(rhs.m_channel)) {
std::swap(m_handle, rhs.m_handle);
}
DigitalInput& DigitalInput::operator=(DigitalInput&& rhs) {
DigitalSource::operator=(std::move(rhs));
m_channel = std::move(rhs.m_channel);
std::swap(m_handle, rhs.m_handle);
return *this;
}
bool DigitalInput::Get() const {
if (StatusIsFatal()) return false;
int32_t status = 0;