refactor: replace for-loop by comment output

This commit is contained in:
ToruNiina
2019-06-28 14:58:47 +09:00
parent 134475e292
commit 284f122433

View File

@@ -633,11 +633,8 @@ format(const basic_value<C, M, V>& v, std::size_t w = 80u,
std::ostringstream oss; std::ostringstream oss;
if(!v.comments().empty()) if(!v.comments().empty())
{ {
for(const auto& c : v.comments()) oss << v.comments();
{ oss << '\n'; // to split the file comment from the first element
oss << '#' << c << '\n';
}
oss << '\n';
} }
oss << visit(serializer<C, M, V>(w, fprec, false), v); oss << visit(serializer<C, M, V>(w, fprec, false), v);
return oss.str(); return oss.str();
@@ -657,11 +654,8 @@ operator<<(std::basic_ostream<charT, traits>& os, const basic_value<C, M, V>& v)
if(!v.comments().empty()) if(!v.comments().empty())
{ {
for(const auto& c : v.comments()) os << v.comments();
{ os << '\n'; // to split the file comment from the first element
os << '#' << c << '\n';
}
os << '\n';
} }
// the root object can't be an inline table. so pass `false`. // the root object can't be an inline table. so pass `false`.
os << visit(serializer<C, M, V>(w, fprec, false), v); os << visit(serializer<C, M, V>(w, fprec, false), v);