Attention une mise à jour du serveur va être effectuée le vendredi 16 avril entre 12h et 12h30. Cette mise à jour va générer une interruption du service de quelques minutes.

Commit 910582b5 authored by BRAMAS Berenger's avatar BRAMAS Berenger

Add copy constructor and operator from rvalue objects for the list and vectro

parent 548c9b34
......@@ -96,6 +96,34 @@ public:
copy(other);
}
/**
* Copy operator
* This will clear the current list before copying
* @param other the source list
* @return the current list as a reference
*/
FList& operator=(FList&& other){
if(&other != this){
clear();
root = other.root;
size = other.size;
other.root = nullptr;
other.size = 0;
}
return *this;
}
/**
* Copy constructor
* @param other the source/original list
*/
FList(FList&& other): root(nullptr) , size(0) {
root = other.root;
size = other.size;
other.root = nullptr;
other.size = 0;
}
/**
* To clear the list
* Size is 0 after calling this function
......
......@@ -77,6 +77,20 @@ public:
}
}
/**
* Copy constructor
* @param other original vector
* object must have an copy constructor
*/
FVector(FVector&& other): array(nullptr), capacity(0), index(0) {
array = other.array;
capacity = other.capacity;
index = other.index;
other.array = nullptr;
other.capacity = 0;
other.index = 0;
}
/** Copy operator
* @param other the original vector
* @return this after copying data
......@@ -103,6 +117,23 @@ public:
return *this;
}
/**
*@brief Copy operator
*/
FVector& operator=(FVector&& other){
if(&other != this){
clear();
delete [] reinterpret_cast< char* >(array);
array = other.array;
capacity = other.capacity;
index = other.index;
other.array = nullptr;
other.capacity = 0;
other.index = 0;
}
return (*this);
}
/**
*@brief destructor
*/
......
Markdown is supported
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