summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoel Klinghed <the_jk@spawned.biz>2023-04-17 21:52:50 +0200
committerJoel Klinghed <the_jk@spawned.biz>2023-04-17 21:52:50 +0200
commita72fca38a681aa37f8c44b5ac384cc9d56860f23 (patch)
tree367c4e2df173baf2086de7fc826979f5cb22a6b7
parenta65df5d6b21233e7058afff0e1cd8e7e0ec193ac (diff)
json: Use the union initialization that is supported in C++17
C++20 has it, and C99 has it, so it works but isn't guaranteed to.
-rw-r--r--src/json.cc9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/json.cc b/src/json.cc
index ac2e15f..aa2bdec 100644
--- a/src/json.cc
+++ b/src/json.cc
@@ -49,13 +49,16 @@ struct ArrayJsonValue : public JsonValue {
struct BasicJsonValue : public JsonValue {
BasicJsonValue(double d)
- : JsonValue(JsonType::DOUBLE), data({ .d = d }) {
+ : JsonValue(JsonType::DOUBLE) {
+ data.d = d;
}
BasicJsonValue(int64_t i)
- : JsonValue(JsonType::INT64), data({ .i = i }) {
+ : JsonValue(JsonType::INT64) {
+ data.i = i;
}
BasicJsonValue(bool b)
- : JsonValue(JsonType::BOOL), data({ .b = b }) {
+ : JsonValue(JsonType::BOOL) {
+ data.b = b;
}
union {
double d;