Skip to content

Commit 60700f5

Browse files
committed
buffer: consume allocator in constructor
Allocator can be not copyable, so it's better to consume it in constructor. It is needed because we are going to use non-copyable allocator for `Buffer` by default. Part of #110
1 parent fa75978 commit 60700f5

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/Buffer/Buffer.hpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
#include <cstring>
3838
#include <string>
3939
#include <type_traits>
40+
#include <utility>
4041

4142
#include "../Utils/Mempool.hpp"
4243
#include "../Utils/List.hpp"
@@ -265,7 +266,7 @@ class Buffer
265266

266267
/** =============== Buffer definition =============== */
267268
/** Copy of any kind is disabled. Move is allowed. */
268-
Buffer(const allocator& all = allocator());
269+
Buffer(allocator &&all = allocator());
269270
Buffer(const Buffer& buf) = delete;
270271
Buffer& operator = (const Buffer& buf) = delete;
271272
Buffer(Buffer &&buf) noexcept = default;
@@ -648,7 +649,7 @@ Buffer<N, allocator>::iterator_common<LIGHT>::moveBackward(size_t step)
648649
}
649650

650651
template <size_t N, class allocator>
651-
Buffer<N, allocator>::Buffer(const allocator &all) : m_all(all)
652+
Buffer<N, allocator>::Buffer(allocator &&all) : m_all(std::forward<allocator>(all))
652653
{
653654
static_assert((N & (N - 1)) == 0, "N must be power of 2");
654655
static_assert(allocator::REAL_SIZE % alignof(Block) == 0,

0 commit comments

Comments
 (0)