[*] Add move constructor

This commit is contained in:
Reece Wilson 2022-01-18 16:56:54 +00:00
parent 09d1db69f2
commit da2b59d083

View File

@ -72,6 +72,25 @@ namespace Aurora::Memory
AuUInt8 scaleSize;// : 4; screw it.... we should just take 6 * (4/8) up to 32/64, we wont go up a slab allocation bucket, whatever you want to call it
///////////////////////////////////////////////////////////////////////
ByteBuffer(ByteBuffer &&buffer)
{
this->base = buffer.base;
this->length = buffer.length;
this->allocSize = buffer.length;
this->writePtr = this->base + (buffer.writePtr - buffer.base);
this->readPtr = this->base + (buffer.readPtr - buffer.base);
this->flagCircular = buffer.flagCircular;
this->flagExpandable = buffer.flagExpandable;
this->scaleSize = buffer.scaleSize;
buffer.base = {};
buffer.length = {};
buffer.allocSize = {};
buffer.writePtr = {};
buffer.readPtr = {};
buffer.flagCircular = {};
buffer.flagExpandable = {};
buffer.scaleSize = {};
}
ByteBuffer(const ByteBuffer &buffer, bool preservePointers = true)
{
@ -92,7 +111,7 @@ namespace Aurora::Memory
std::memcpy(this->base, buffer.base, this->length);
this->flagCircular = buffer.flagCircular;
this->flagExpandable = buffer.flagExpandable;
this->scaleSize = kBufferInitialPower;
this->scaleSize = buffer.scaleSize;
}
ByteBuffer(const void *in, AuUInt length, bool circular = false, bool expandable = false) : flagCircular(circular), flagExpandable(expandable), flagReadError(0), flagWriteError(0)