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
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user