tag/Tag: Merge() returns Tag, MergePtr() returns std::unique_ptr<Tag>

This commit is contained in:
Max Kellermann
2021-08-05 17:31:31 +02:00
parent 955502f881
commit 7d69cbbda7
4 changed files with 19 additions and 8 deletions

View File

@@ -53,8 +53,16 @@ Tag::Tag(const Tag &other) noexcept
}
}
std::unique_ptr<Tag>
Tag
Tag::Merge(const Tag &base, const Tag &add) noexcept
{
TagBuilder builder(add);
builder.Complement(base);
return builder.Commit();
}
std::unique_ptr<Tag>
Tag::MergePtr(const Tag &base, const Tag &add) noexcept
{
TagBuilder builder(add);
builder.Complement(base);
@@ -70,7 +78,7 @@ Tag::Merge(std::unique_ptr<Tag> base, std::unique_ptr<Tag> add) noexcept
if (base == nullptr)
return add;
return Merge(*base, *add);
return MergePtr(*base, *add);
}
const char *

View File

@@ -117,8 +117,11 @@ struct Tag {
*
* @return a newly allocated tag
*/
static std::unique_ptr<Tag> Merge(const Tag &base,
const Tag &add) noexcept;
static Tag Merge(const Tag &base,
const Tag &add) noexcept;
static std::unique_ptr<Tag> MergePtr(const Tag &base,
const Tag &add) noexcept;
/**
* Merges the data from two tags. Any of the two may be nullptr. Both