dropbox / json11

A tiny JSON library for C++11.
MIT License
2.54k stars 613 forks source link

clang 6.0 compilation error #122

Closed Yanpas closed 6 years ago

Yanpas commented 6 years ago
            ^
.../src/json11.cpp:157:24:error:
      invalid operands to binary expression ('nullptr_t' and 'nullptr_t')
  ...m_value < static_cast<const Value<tag, T> *>(other)->m_value;
     ~~~~~~~ ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.../src/json11.cpp:213:5: note:
      in instantiation of member function
      'json11::Value<json11::Json::NUL, nullptr_t>::less' requested here
    JsonNull() : Value(nullptr) {}
    ^
1 error generated.
Yanpas commented 6 years ago

Patch to fix it:

@@ -208,7 +208,7 @@
     explicit JsonObject(Json::object &&value)      : Value(move(value)) {}
 };

-class JsonNull final : public Value<Json::NUL, std::nullptr_t> {
+class JsonNull final : public Value<Json::NUL, void*> {
 public:
     JsonNull() : Value(nullptr) {}
 };
artwyman commented 6 years ago

I think you're using an older version of json11 (the line numbers in your error message don't match up with the latest master). The issue you mentioned was already fixed in alternative way using the NullStruct helper: https://github.com/dropbox/json11/blob/master/json11.cpp#L220 If you pull the latest you should be all set.