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/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() {