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/DigitalOutput.h"
|
||||
|
||||
#include <limits>
|
||||
#include <utility>
|
||||
|
||||
#include <hal/DIO.h>
|
||||
#include <hal/HAL.h>
|
||||
@@ -51,6 +52,25 @@ DigitalOutput::~DigitalOutput() {
|
||||
HAL_FreeDIOPort(m_handle);
|
||||
}
|
||||
|
||||
DigitalOutput::DigitalOutput(DigitalOutput&& rhs)
|
||||
: ErrorBase(std::move(rhs)),
|
||||
SendableBase(std::move(rhs)),
|
||||
m_channel(std::move(rhs.m_channel)),
|
||||
m_pwmGenerator(std::move(rhs.m_pwmGenerator)) {
|
||||
std::swap(m_handle, rhs.m_handle);
|
||||
}
|
||||
|
||||
DigitalOutput& DigitalOutput::operator=(DigitalOutput&& rhs) {
|
||||
ErrorBase::operator=(std::move(rhs));
|
||||
SendableBase::operator=(std::move(rhs));
|
||||
|
||||
m_channel = std::move(rhs.m_channel);
|
||||
std::swap(m_handle, rhs.m_handle);
|
||||
m_pwmGenerator = std::move(rhs.m_pwmGenerator);
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
void DigitalOutput::Set(bool value) {
|
||||
if (StatusIsFatal()) return;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user