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/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;
|
||||
|
||||
Reference in New Issue
Block a user