early-access version 3565

This commit is contained in:
pineappleEA
2023-05-07 21:53:35 +02:00
parent cdb7d0d547
commit ee3e26bfd1
5 changed files with 32 additions and 13 deletions

View File

@@ -23,7 +23,10 @@ public:
buffer{Common::make_unique_for_overwrite<T[]>(initial_capacity)} {}
~ScratchBuffer() = default;
ScratchBuffer(const ScratchBuffer&) = delete;
ScratchBuffer& operator=(const ScratchBuffer&) = delete;
ScratchBuffer(ScratchBuffer&&) = default;
ScratchBuffer& operator=(ScratchBuffer&&) = default;
/// This will only grow the buffer's capacity if size is greater than the current capacity.
/// The previously held data will remain intact.
@@ -87,6 +90,18 @@ public:
return buffer_capacity;
}
void swap(ScratchBuffer& other) {
std::swap(last_requested_size, other.last_requested_size);
std::swap(buffer_capacity, other.buffer_capacity);
std::swap(buffer, other.buffer);
}
void swap(ScratchBuffer&& other) {
std::swap(last_requested_size, other.last_requested_size);
std::swap(buffer_capacity, other.buffer_capacity);
std::swap(buffer, other.buffer);
}
private:
size_t last_requested_size{};
size_t buffer_capacity{};