From e8e37680eedb0c687f26e5415c9843ff4c8bc865 Mon Sep 17 00:00:00 2001 From: Leonidas Boulougaris Date: Mon, 27 Sep 2021 02:09:19 +0300 Subject: [PATCH 1/2] Fixed compile error related to std::string in JSONOutputArchive JSONOutputArchive expected an std::string param to be passed saveValue(). This caused the compilation to fail when the more generic std::basic_string was passed and not an std::string. This fix changes the signature of saveValue to expect an std::basic_string --- include/cereal/archives/json.hpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/include/cereal/archives/json.hpp b/include/cereal/archives/json.hpp index 456b6893..cac3f7dc 100644 --- a/include/cereal/archives/json.hpp +++ b/include/cereal/archives/json.hpp @@ -255,7 +255,8 @@ namespace cereal //! Saves a double to the current node void saveValue(double d) { itsWriter.Double(d); } //! Saves a string to the current node - void saveValue(std::string const & s) { itsWriter.String(s.c_str(), static_cast( s.size() )); } + template inline + void saveValue(std::basic_stringconst& s) { itsWriter.String(s.c_str(), static_cast(s.size())); } //! Saves a const char * to the current node void saveValue(char const * s) { itsWriter.String(s); } //! Saves a nullptr to the current node From d6d7c058e0058a8ad7e7a4219e877576669a7b95 Mon Sep 17 00:00:00 2001 From: Leonidas Boulougaris Date: Mon, 27 Sep 2021 02:15:37 +0300 Subject: [PATCH 2/2] Fixed compile error related to std::string in JSONOutputArchive JSONOutputArchive expected an std::string param to be passed to loadValue(). This caused the compilation to fail when the more generic std::basic_string was passed and not an std::string. This fix changes the signature of loadValue to expect an std::basic_string --- include/cereal/archives/json.hpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/include/cereal/archives/json.hpp b/include/cereal/archives/json.hpp index cac3f7dc..43b4265d 100644 --- a/include/cereal/archives/json.hpp +++ b/include/cereal/archives/json.hpp @@ -656,7 +656,8 @@ namespace cereal //! Loads a value from the current node - double overload void loadValue(double & val) { search(); val = itsIteratorStack.back().value().GetDouble(); ++itsIteratorStack.back(); } //! Loads a value from the current node - string overload - void loadValue(std::string & val) { search(); val = itsIteratorStack.back().value().GetString(); ++itsIteratorStack.back(); } + template inline + void loadValue(std::basic_string & val) { search(); val = itsIteratorStack.back().value().GetString(); ++itsIteratorStack.back(); } //! Loads a nullptr from the current node void loadValue(std::nullptr_t&) { search(); CEREAL_RAPIDJSON_ASSERT(itsIteratorStack.back().value().IsNull()); ++itsIteratorStack.back(); }