From 52a3af664f40775426b189c85b6088d436d05df3 Mon Sep 17 00:00:00 2001 From: Vitaliy Filippov Date: Sat, 15 Jan 2022 23:38:58 +0300 Subject: [PATCH] Fix compilation under clang --- json11.cpp | 34 ++++++++++++++++++++-------------- 1 file changed, 20 insertions(+), 14 deletions(-) diff --git a/json11.cpp b/json11.cpp index 3ea51c1..ae37004 100644 --- a/json11.cpp +++ b/json11.cpp @@ -41,10 +41,6 @@ using std::move; * Serialization */ -static void dump(std::nullptr_t, string &out) { - out += "null"; -} - static void dump(double value, string &out) { if (std::isfinite(value)) { char buf[32]; @@ -55,10 +51,6 @@ static void dump(double value, string &out) { } } -static void dump(int value, string &out) { - out += std::to_string(value); -} - static void dump(int64_ value, string &out) { out += std::to_string(value); } @@ -169,7 +161,7 @@ protected: }; class JsonDouble final : public Value { - string as_string() const { return std::to_string(m_value); } + string as_string() const override { return std::to_string(m_value); } bool bool_value() const override { return m_value != 0; } double number_value() const override { return static_cast(m_value); } int64_ int64_value() const override { return static_cast(m_value); } @@ -181,7 +173,7 @@ public: }; class JsonInt64 final : public Value { - string as_string() const { return std::to_string(m_value); } + string as_string() const override { return std::to_string(m_value); } bool bool_value() const override { return m_value != 0; } double number_value() const override { return static_cast(m_value); } int64_ int64_value() const override { return static_cast(m_value); } @@ -193,7 +185,7 @@ public: }; class JsonUInt64 final : public Value { - string as_string() const { return std::to_string(m_value); } + string as_string() const override { return std::to_string(m_value); } bool bool_value() const override { return m_value != 0; } double number_value() const override { return static_cast(m_value); } int64_ int64_value() const override { return static_cast(m_value); } @@ -211,7 +203,7 @@ public: }; class JsonString final : public Value { - string as_string() const { return m_value; } + string as_string() const override { return m_value; } const string &string_value() const override { return m_value; } bool bool_value() const override { return m_value != "" && m_value != "0"; } double number_value() const override @@ -259,9 +251,23 @@ public: explicit JsonObject(Json::object &&value) : Value(move(value)) {} }; -class JsonNull final : public Value { +class JsonNull final : public JsonValue { public: - JsonNull() : Value(nullptr) {} + JsonNull() {} + // Get type tag + Json::Type type() const override { + return Json::NUL; + } + // Comparisons - only within type + bool equals(const JsonValue * other) const override { + return true; + } + bool less(const JsonValue * other) const override { + return false; + } + void dump(string &out) const override { + out += "null"; + } }; /* * * * * * * * * * * * * * * * * * * *