Commit c36af357 authored by Max Kellermann's avatar Max Kellermann

TagBuilder: add move operator

parent 424f478c
...@@ -72,6 +72,37 @@ TagBuilder::operator=(const TagBuilder &other) ...@@ -72,6 +72,37 @@ TagBuilder::operator=(const TagBuilder &other)
return *this; return *this;
} }
TagBuilder &
TagBuilder::operator=(TagBuilder &&other)
{
time = other.time;
has_playlist = other.has_playlist;
items = std::move(other.items);
return *this;
}
TagBuilder &
TagBuilder::operator=(Tag &&other)
{
time = other.time;
has_playlist = other.has_playlist;
/* move all TagItem pointers from the Tag object; we don't
need to contact the tag pool, because all we do is move
references */
items.clear();
items.reserve(other.num_items);
std::copy_n(other.items, other.num_items, std::back_inserter(items));
/* discard the pointers from the Tag object */
other.num_items = 0;
delete[] other.items;
other.items = nullptr;
return *this;
}
void void
TagBuilder::Clear() TagBuilder::Clear()
{ {
......
...@@ -68,6 +68,9 @@ public: ...@@ -68,6 +68,9 @@ public:
explicit TagBuilder(Tag &&other); explicit TagBuilder(Tag &&other);
TagBuilder &operator=(const TagBuilder &other); TagBuilder &operator=(const TagBuilder &other);
TagBuilder &operator=(TagBuilder &&other);
TagBuilder &operator=(Tag &&other);
/** /**
* Returns true if the tag contains no items. This ignores the "time" * Returns true if the tag contains no items. This ignores the "time"
......
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