From ffe216b3507e1458c57172c8523273783f3a5d39 Mon Sep 17 00:00:00 2001 From: OEOTYAN <1124718975@qq.com> Date: Wed, 6 Dec 2023 22:11:38 +0800 Subject: [PATCH] comment: add comments to CompoundTagVariant --- src/mc/nbt/CompoundTagVariant.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/mc/nbt/CompoundTagVariant.h b/src/mc/nbt/CompoundTagVariant.h index 34e779314f..9c06d7c25e 100644 --- a/src/mc/nbt/CompoundTagVariant.h +++ b/src/mc/nbt/CompoundTagVariant.h @@ -105,7 +105,7 @@ class CompoundTagVariant { [[nodiscard]] bool hold() const noexcept { return std::holds_alternative(mTagStorage); } - + // consistency with json [[nodiscard]] bool is_array() const noexcept { return hold(); } [[nodiscard]] bool is_binary() const noexcept { return hold() || hold(); } [[nodiscard]] bool is_boolean() const noexcept { return hold(); } @@ -114,9 +114,9 @@ class CompoundTagVariant { [[nodiscard]] bool is_number_integer() const noexcept { return hold() || hold() || hold() || hold(); } - [[nodiscard]] bool is_number() const noexcept { return is_number_float() || is_number_integer(); } [[nodiscard]] bool is_object() const noexcept { return hold(); } [[nodiscard]] bool is_string() const noexcept { return hold(); } + [[nodiscard]] bool is_number() const noexcept { return is_number_float() || is_number_integer(); } [[nodiscard]] bool is_primitive() const noexcept { return is_null() || is_string() || is_number() || is_binary(); } [[nodiscard]] bool is_structured() const noexcept { return is_array() || is_object(); } @@ -183,7 +183,7 @@ class CompoundTagVariant { } [[nodiscard]] CompoundTagVariant& operator[](std::string const& index) { - if (hold()) { + if (is_null()) { mTagStorage = CompoundTag{}; } if (!hold()) { @@ -213,7 +213,7 @@ class CompoundTagVariant { } void push_back(CompoundTagVariant val) { - if (hold()) { + if (is_null()) { mTagStorage = ListTag{}; } if (!hold()) {