@@ -264,11 +264,28 @@ class Buffer {
264
264
265
265
/* * =============== Buffer definition =============== */
266
266
/* * Copy of any kind is disabled. Move is allowed. */
267
- Buffer (const allocator& all = allocator());
267
+ Buffer (allocator& & all = allocator());
268
268
Buffer (const Buffer& buf) = delete ;
269
269
Buffer& operator = (const Buffer& buf) = delete ;
270
- Buffer (Buffer &&buf) noexcept = default ;
271
- Buffer &operator =(Buffer &&buf) noexcept = default ;
270
+ Buffer (Buffer &&other) noexcept
271
+ {
272
+ /* Call move assignment operator. */
273
+ *this = std::forward<Buffer>(other);
274
+ }
275
+ Buffer &operator =(Buffer &&other)
276
+ {
277
+ if (this == &other)
278
+ return *this ;
279
+ m_blocks = std::move (other.m_blocks );
280
+ assert (other.m_blocks .isEmpty ());
281
+ m_iterators = std::move (other.m_iterators );
282
+ m_begin = other.m_begin ;
283
+ other.m_begin = nullptr ;
284
+ m_end = other.m_end ;
285
+ other.m_end = nullptr ;
286
+ m_all = std::move (other.m_all );
287
+ return *this ;
288
+ }
272
289
~Buffer () noexcept ;
273
290
274
291
/* *
@@ -647,7 +664,7 @@ Buffer<N, allocator>::iterator_common<LIGHT>::moveBackward(size_t step)
647
664
}
648
665
649
666
template <size_t N, class allocator >
650
- Buffer<N, allocator>::Buffer(const allocator &all) : m_all(all)
667
+ Buffer<N, allocator>::Buffer(allocator && all) : m_all(std::forward<allocator>( all) )
651
668
{
652
669
static_assert ((N & (N - 1 )) == 0 , " N must be power of 2" );
653
670
static_assert (allocator::REAL_SIZE % alignof (Block) == 0 ,
0 commit comments