Commit b0b8bc61 authored by Steffen Müthing's avatar Steffen Müthing
Browse files

Make AlignedVector copyable

This is required for the splitting constructor of the sumfactorized
local operator.
parent 3054148b
......@@ -243,6 +243,11 @@ public:
}
}
AlignedVector()
: n(0)
, p(nullptr)
{}
//! copy constructor
AlignedVector (const AlignedVector& vec)
{
......@@ -251,10 +256,23 @@ public:
if (p==0) throw std::bad_alloc();
}
//! assignment operator
AlignedVector& operator=(const AlignedVector& vec)
{
if (p)
aligned_free(p);
n = vec.n;
p = (T*) aligned_malloc(n*sizeof(T),alignment);
if (p==0) throw std::bad_alloc();
std::copy(vec.p,vec.p+n,p);
return *this;
}
//! free vector
~AlignedVector ()
{
aligned_free(p);
if (p)
aligned_free(p);
}
//! resize vector
......@@ -265,7 +283,8 @@ public:
n = _n;
return;
}
aligned_free(p);
if (p)
aligned_free(p);
n = _n;
p = (T*) aligned_malloc(n*sizeof(T),alignment);
if (p==0) throw std::bad_alloc();
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment