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

@@ -7,6 +7,8 @@
#include "frc/I2C.h"
#include <utility>
#include <hal/HAL.h>
#include <hal/I2C.h>
@@ -25,6 +27,21 @@ I2C::I2C(Port port, int deviceAddress)
I2C::~I2C() { HAL_CloseI2C(m_port); }
I2C::I2C(I2C&& rhs)
: ErrorBase(std::move(rhs)),
m_deviceAddress(std::move(rhs.m_deviceAddress)) {
std::swap(m_port, rhs.m_port);
}
I2C& I2C::operator=(I2C&& rhs) {
ErrorBase::operator=(std::move(rhs));
std::swap(m_port, rhs.m_port);
m_deviceAddress = std::move(rhs.m_deviceAddress);
return *this;
}
bool I2C::Transaction(uint8_t* dataToSend, int sendSize, uint8_t* dataReceived,
int receiveSize) {
int32_t status = 0;