add asignement operator

git-svn-id: svn://scm.gforge.inria.fr/svnroot/paradiseo@2369 331e1502-861f-0410-8da2-ba01fb791d7f
This commit is contained in:
boufaras 2011-09-14 13:16:49 +00:00
commit 37835557fc

View file

@ -62,12 +62,11 @@ template<class ElemT, class Fitness>
/** /**
*Constructor. *Constructor.
*@param _neighborhoodSize The neighborhood size. *@param _size The solution size.
*/ */
moGPUVector(unsigned _neighborhoodSize) : moGPUVector(unsigned _size) :
N(_neighborhoodSize) { N(_size) {
vect = new ElemType[N]; vect = new ElemType[N];
} }
@ -113,12 +112,13 @@ template<class ElemT, class Fitness>
moGPUVector& operator=(const moGPUVector & _vector) { moGPUVector& operator=(const moGPUVector & _vector) {
if (!(N == _vector.N)) { if (!(N == _vector.N)) {
delete[] vect;
N = _vector.N; N = _vector.N;
vect = new ElemType[N]; vect = new ElemType[N];
} }
for (unsigned i = 0; i < N; i++) for (unsigned i = 0; i < N; i++){
vect[i] = _vector.vect[i]; vect[i] = _vector[i];
}
if (!(_vector.invalid())) if (!(_vector.invalid()))
fitness(_vector.fitness()); fitness(_vector.fitness());
else else