6 template<
unsigned alignBytes = 16>
28 if (
m_ptr == NULL) ptr = _aligned_malloc(s, alignBytes);
29 else ptr = _aligned_realloc(
m_ptr, s, alignBytes);
30 if ( ptr == NULL )
throw std::bad_alloc();
33 if ((ptr = memalign( alignBytes, s )) == NULL)
throw std::bad_alloc();
35 if (posix_memalign( &ptr, alignBytes, s ) < 0)
throw std::bad_alloc();
61 memcpy(
ptr(), other.ptr(),
size());
66 other.m_ptr = NULL; other.m_size = 0;
72 other.m_ptr = NULL; other.m_size = 0;
89 template<
typename obj_t,
unsigned alignBytes = 16>
95 size_t size()
const {
return m.size() /
sizeof(obj_t); }
97 obj_t *
ptr() {
return reinterpret_cast<obj_t*
>(m.ptr()); }
98 const obj_t *
ptr()
const {
return reinterpret_cast<const obj_t*
>(m.ptr()); }
99 obj_t *
get_ptr() {
return reinterpret_cast<obj_t*
>(m.ptr()); }
100 const obj_t *
get_ptr()
const {
return reinterpret_cast<const obj_t*
>(m.ptr()); }
104 self_t
const &
operator=(self_t
const & other) {m = other.m;
return *
this;}
105 self_t
const &
operator=(self_t && other) {m = std::move(other.m);
return *
this;}
110 template<
typename obj_t,
unsigned alignBytes = 16>
117 m.resize( multiply_guarded<size_t>(s, 3) / 2 );
126 obj_t *
ptr() {
return m.ptr(); }
127 const obj_t *
ptr()
const {
return m.ptr(); }
129 const obj_t *
get_ptr()
const {
return m.ptr(); }
133 self_t
const &
operator=(self_t
const & other) {m = other.m;
m_size = other.m_size;
return *
this;}
134 self_t
const &
operator=(self_t && other) {m = std::move(other.m);
m_size = other.m_size; other.m_size = 0;
return *
this;}
const obj_t * ptr() const
mem_block_aligned(self_t &&other)
mem_block_aligned_t(self_t &&other)
mem_block_aligned_incremental_t()
mem_block_aligned< alignBytes > self_t
const void * get_ptr() const
mem_block_aligned(self_t const &other)
t_int multiply_guarded(t_int v1, t_int v2)
self_t const & operator=(self_t const &other)
mem_block_aligned_t< obj_t, alignBytes > m
self_t const & operator=(self_t &&other)
self_t const & operator=(self_t const &other)
self_t const & operator=(self_t const &other)
const obj_t * get_ptr() const
mem_block_aligned< alignBytes > m
mem_block_aligned_incremental_t(self_t const &other)
mem_block_aligned_t< obj_t, alignBytes > self_t
mem_block_aligned_incremental_t(self_t &&other)
void assign(self_t const &other)
mem_block_aligned_t(self_t const &other)
self_t const & operator=(self_t &&other)
static void _free(void *ptr)
self_t const & operator=(self_t &&other)
const obj_t * ptr() const
const obj_t * get_ptr() const
mem_block_aligned_t< obj_t, alignBytes > self_t