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/Solenoid.h"
|
||||
|
||||
#include <utility>
|
||||
|
||||
#include <hal/HAL.h>
|
||||
#include <hal/Ports.h>
|
||||
#include <hal/Solenoid.h>
|
||||
@@ -50,6 +52,20 @@ Solenoid::Solenoid(int moduleNumber, int channel)
|
||||
|
||||
Solenoid::~Solenoid() { HAL_FreeSolenoidPort(m_solenoidHandle); }
|
||||
|
||||
Solenoid::Solenoid(Solenoid&& rhs)
|
||||
: SolenoidBase(std::move(rhs)), m_channel(std::move(rhs.m_channel)) {
|
||||
std::swap(m_solenoidHandle, rhs.m_solenoidHandle);
|
||||
}
|
||||
|
||||
Solenoid& Solenoid::operator=(Solenoid&& rhs) {
|
||||
SolenoidBase::operator=(std::move(rhs));
|
||||
|
||||
std::swap(m_solenoidHandle, rhs.m_solenoidHandle);
|
||||
m_channel = std::move(rhs.m_channel);
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
void Solenoid::Set(bool on) {
|
||||
if (StatusIsFatal()) return;
|
||||
int32_t status = 0;
|
||||
|
||||
Reference in New Issue
Block a user