Skip to content
Snippets Groups Projects
Commit c77d4edf authored by Jan Trávníček's avatar Jan Trávníček
Browse files

move semantics

parent 2ec4e094
No related branches found
No related tags found
No related merge requests found
......@@ -19,24 +19,27 @@ Alternation::Alternation(const Alternation& other) {
}
}
 
Alternation::Alternation(Alternation&& other) noexcept : elements(std::move(other.elements)) {
other.elements.clear();
}
Alternation& Alternation::operator=(const Alternation& other) {
if (this == &other) {
return *this;
}
 
for (auto element : elements) {
delete element;
}
elements.clear();
*this = Alternation(other);
 
for (const auto& element : other.elements) {
elements.push_back(element->clone());
}
return *this;
}
 
Alternation& Alternation::operator=(Alternation&& other) {
std::swap(this->elements, other.elements);
return *this;
}
 
Alternation::~Alternation() {
Alternation::~Alternation() noexcept {
for (auto element : elements) {
delete element;
}
......
......@@ -23,8 +23,10 @@ private:
public:
Alternation();
Alternation(const Alternation& other);
Alternation(Alternation&& other) noexcept;
Alternation& operator =(const Alternation& other);
~Alternation();
Alternation& operator =(Alternation&& other);
~Alternation() noexcept;
 
/**
* @return list of operands
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment