diff options
Diffstat (limited to 'src/common/scratch_buffer.h')
| -rw-r--r-- | src/common/scratch_buffer.h | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/common/scratch_buffer.h b/src/common/scratch_buffer.h index 26d4e76dc..a69a5a7af 100644 --- a/src/common/scratch_buffer.h +++ b/src/common/scratch_buffer.h | |||
| @@ -23,7 +23,10 @@ public: | |||
| 23 | buffer{Common::make_unique_for_overwrite<T[]>(initial_capacity)} {} | 23 | buffer{Common::make_unique_for_overwrite<T[]>(initial_capacity)} {} |
| 24 | 24 | ||
| 25 | ~ScratchBuffer() = default; | 25 | ~ScratchBuffer() = default; |
| 26 | ScratchBuffer(const ScratchBuffer&) = delete; | ||
| 27 | ScratchBuffer& operator=(const ScratchBuffer&) = delete; | ||
| 26 | ScratchBuffer(ScratchBuffer&&) = default; | 28 | ScratchBuffer(ScratchBuffer&&) = default; |
| 29 | ScratchBuffer& operator=(ScratchBuffer&&) = default; | ||
| 27 | 30 | ||
| 28 | /// This will only grow the buffer's capacity if size is greater than the current capacity. | 31 | /// This will only grow the buffer's capacity if size is greater than the current capacity. |
| 29 | /// The previously held data will remain intact. | 32 | /// The previously held data will remain intact. |
| @@ -87,6 +90,12 @@ public: | |||
| 87 | return buffer_capacity; | 90 | return buffer_capacity; |
| 88 | } | 91 | } |
| 89 | 92 | ||
| 93 | void swap(ScratchBuffer& other) noexcept { | ||
| 94 | std::swap(last_requested_size, other.last_requested_size); | ||
| 95 | std::swap(buffer_capacity, other.buffer_capacity); | ||
| 96 | std::swap(buffer, other.buffer); | ||
| 97 | } | ||
| 98 | |||
| 90 | private: | 99 | private: |
| 91 | size_t last_requested_size{}; | 100 | size_t last_requested_size{}; |
| 92 | size_t buffer_capacity{}; | 101 | size_t buffer_capacity{}; |