███████████: development [#METR-8766].

This commit is contained in:
Alexey Milovidov 2014-03-14 00:12:40 +04:00
parent 1e44f91f00
commit ccc3da3148

View File

@ -20,12 +20,12 @@ namespace DB
*/ */
struct Memory : boost::noncopyable struct Memory : boost::noncopyable
{ {
size_t m_capacity; size_t m_capacity = 0;
size_t m_size; size_t m_size = 0;
char * m_data; char * m_data = nullptr;
size_t alignment; size_t alignment = 0;
Memory() : m_capacity(0), m_size(0), m_data(NULL), alignment(0) {} Memory() {}
/// Если alignment != 0, то будет выделяться память, выровненная на alignment. /// Если alignment != 0, то будет выделяться память, выровненная на alignment.
Memory(size_t size_, size_t alignment_ = 0) : m_capacity(size_), m_size(m_capacity), alignment(alignment_) Memory(size_t size_, size_t alignment_ = 0) : m_capacity(size_), m_size(m_capacity), alignment(alignment_)
@ -38,6 +38,21 @@ struct Memory : boost::noncopyable
dealloc(); dealloc();
} }
Memory(Memory && rhs)
{
*this = std::move(rhs);
}
Memory & operator=(Memory && rhs)
{
std::swap(m_capacity, rhs.m_capacity);
std::swap(m_size, rhs.m_size);
std::swap(m_data, rhs.m_data);
std::swap(alignment, rhs.alignment);
return *this;
}
size_t size() const { return m_size; } size_t size() const { return m_size; }
const char & operator[](size_t i) const { return m_data[i]; } const char & operator[](size_t i) const { return m_data[i]; }
char & operator[](size_t i) { return m_data[i]; } char & operator[](size_t i) { return m_data[i]; }