From 92aa42a58e3c418f7804b44eac0c1dd3c17d5454 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marius=20Maa=C3=9F?= Date: Thu, 2 Jul 2020 13:36:20 +0200 Subject: [PATCH] Fix MSVC warning C4866 This fixes the warning "compiler may not enforce left-to-right evaluation order for call to" that is caused by Visual Studio if this is compiled with a target of C++17. --- toml/serializer.hpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/toml/serializer.hpp b/toml/serializer.hpp index 46a2b70..c733582 100644 --- a/toml/serializer.hpp +++ b/toml/serializer.hpp @@ -697,7 +697,8 @@ format(const basic_value& v, std::size_t w = 80u, oss << v.comments(); oss << '\n'; // to split the file comment from the first element } - oss << visit(serializer(w, fprec, no_comment, false), v); + const auto serialized = visit(serializer(w, fprec, no_comment, false), v); + oss << serialized; return oss.str(); } return visit(serializer(w, fprec, force_inline), v); @@ -753,7 +754,8 @@ operator<<(std::basic_ostream& os, const basic_value& v) os << '\n'; // to split the file comment from the first element } // the root object can't be an inline table. so pass `false`. - os << visit(serializer(w, fprec, false, no_comment), v); + const auto serialized = visit(serializer(w, fprec, no_comment, false), v); + os << serialized; // if v is a non-table value, and has only one comment, then // put a comment just after a value. in the following way.