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/SPI.h"
|
||||
|
||||
#include <cstring>
|
||||
#include <utility>
|
||||
|
||||
#include <hal/HAL.h>
|
||||
#include <hal/SPI.h>
|
||||
@@ -138,6 +139,27 @@ SPI::SPI(Port port) : m_port(static_cast<HAL_SPIPort>(port)) {
|
||||
|
||||
SPI::~SPI() { HAL_CloseSPI(m_port); }
|
||||
|
||||
SPI::SPI(SPI&& rhs)
|
||||
: ErrorBase(std::move(rhs)),
|
||||
m_msbFirst(std::move(rhs.m_msbFirst)),
|
||||
m_sampleOnTrailing(std::move(rhs.m_sampleOnTrailing)),
|
||||
m_clockIdleHigh(std::move(rhs.m_clockIdleHigh)),
|
||||
m_accum(std::move(rhs.m_accum)) {
|
||||
std::swap(m_port, rhs.m_port);
|
||||
}
|
||||
|
||||
SPI& SPI::operator=(SPI&& rhs) {
|
||||
ErrorBase::operator=(std::move(rhs));
|
||||
|
||||
std::swap(m_port, rhs.m_port);
|
||||
m_msbFirst = std::move(rhs.m_msbFirst);
|
||||
m_sampleOnTrailing = std::move(rhs.m_sampleOnTrailing);
|
||||
m_clockIdleHigh = std::move(rhs.m_clockIdleHigh);
|
||||
m_accum = std::move(rhs.m_accum);
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
void SPI::SetClockRate(double hz) { HAL_SetSPISpeed(m_port, hz); }
|
||||
|
||||
void SPI::SetMSBFirst() {
|
||||
|
||||
Reference in New Issue
Block a user