From 3fce691faeb8e158042d3e6b8dc6fd8ce8c74c62 Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Fri, 15 Jun 2018 15:33:32 -0700 Subject: [PATCH] Use a regular constructor instead of aggregate initialization --- src/scanner.cc | 2 +- src/tag.h | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/scanner.cc b/src/scanner.cc index 6458031..058e48f 100644 --- a/src/scanner.cc +++ b/src/scanner.cc @@ -47,7 +47,7 @@ struct Scanner { unsigned i = 0; while (i < length) { - Tag tag { static_cast(buffer[i]), "" }; + Tag tag(static_cast(buffer[i]), ""); i++; if (tag.type == CUSTOM) { unsigned length = buffer[i++]; diff --git a/src/tag.h b/src/tag.h index 8eb1046..c4f48fb 100644 --- a/src/tag.h +++ b/src/tag.h @@ -303,6 +303,8 @@ struct Tag { TagType type; string custom_tag_name; + Tag(TagType type, const string &name) : type(type), custom_tag_name(name) {} + bool operator==(const Tag &other) const { if (type != other.type) return false; if (type == TagType::CUSTOM && custom_tag_name != other.custom_tag_name) return false; @@ -360,8 +362,9 @@ struct Tag { static inline Tag for_name(const string &name) { unordered_map::const_iterator type = TAG_TYPES_BY_TAG_NAME.find(name); if (type != TAG_TYPES_BY_TAG_NAME.end()) { - return Tag { type->second, "" }; + return Tag(type->second, string()); + } else { + return Tag(CUSTOM, name); } - return Tag { CUSTOM, name }; } };