From 7740c71ecedd90f9b465dc35994e64915dbda826 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Fri, 7 Oct 2022 10:10:01 +0200 Subject: a --- serialize/json-helper.hpp | 2 +- serialize/magnum-vector.hpp | 7 +++++-- serialize/magnum-vector2i.hpp | 4 ++-- 3 files changed, 8 insertions(+), 5 deletions(-) (limited to 'serialize') diff --git a/serialize/json-helper.hpp b/serialize/json-helper.hpp index 6be7f74c..b8e290b7 100644 --- a/serialize/json-helper.hpp +++ b/serialize/json-helper.hpp @@ -9,7 +9,7 @@ struct json_helper final { template [[nodiscard]] - static std::tuple from_json(const std::filesystem::path& pathname); + static std::tuple from_json(const std::filesystem::path& pathname); template [[nodiscard]] diff --git a/serialize/magnum-vector.hpp b/serialize/magnum-vector.hpp index 8ea5e13a..61e127b1 100644 --- a/serialize/magnum-vector.hpp +++ b/serialize/magnum-vector.hpp @@ -22,13 +22,16 @@ void adl_serializer>::to_json(json& j, const vec& val std::array array{}; for (std::size_t i = 0; i < N; i++) array[i] = val[i]; - j = array; + using nlohmann::to_json; + to_json(j, array); } template void adl_serializer>::from_json(const json& j, vec& val) { - std::array array = j; + std::array array{}; + using nlohmann::from_json; + from_json(j, array); for (std::size_t i = 0; i < N; i++) val[i] = array[i]; } diff --git a/serialize/magnum-vector2i.hpp b/serialize/magnum-vector2i.hpp index eb445e21..c8c52e7e 100644 --- a/serialize/magnum-vector2i.hpp +++ b/serialize/magnum-vector2i.hpp @@ -27,12 +27,12 @@ struct adl_serializer> final { type x = 0, y = 0; int n = 0; int ret = std::sscanf(str.c_str(), format_string, &x, &y, &n); - if (ret != 2 || (std::size_t)n != str.size() || x != (type)x || y != (type)y) + if (ret != 2 || (std::size_t)n != str.size() || x != (t)x || y != (t)y) { std::string msg; msg.reserve(128); msg += "failed to parse string '"; msg += str; - msg += "' as Magnum::Vector2i"; + msg += "' as Magnum::Vector2"; throw std::invalid_argument(msg); } val = { (t)x, (t)y }; -- cgit v1.2.3