9#ifndef BHEAP_MEMORY_HPP
10#define BHEAP_MEMORY_HPP
18typedef unsigned char byte;
20#define MEM_ALIGNMENT 32
45template<
typename Memory>
69 :Memory((Memory &&)mem),
buf_sz(mem.size())
94 bool ret = Memory::allocate(sz);
113 bool ret = Memory::resize(sz);
140 return Memory::size();
153 static_cast<Memory *
>(
this)->
operator=(mem);
168 static_cast<Memory *
>(
this)->
operator=(mem);
192 size_t buf_sz_t = mem.
buf_sz;
It override the behavior if size()
BMemory & operator=(BMemory< Memory > &&mem)
Copy the memory.
void swap(BMemory< Memory > &mem)
swap the two memory object
virtual ~BMemory() noexcept
Destructor.
virtual bool allocate(size_t sz)
allocate the memory
BMemory(const BMemory< Memory > &mem)
Copy the Heap memory.
BMemory & operator=(const BMemory< Memory > &mem)
Copy the memory.
virtual bool resize(size_t sz)
Resize the allocated memory.
BMemory()
Constructor, we choose a default alignment of 32 for avx.
size_t msize()
Return the memory size.
size_t buf_sz
size of the memory
BMemory(BMemory< Memory > &&mem) noexcept
Copy the Heap memory.
void destroy()
Destroy the internal memory.
virtual size_t size() const
Resize the buffer size.