mirror of
https://github.com/ToruNiina/toml11.git
synced 2025-09-17 17:28:12 +08:00
refactor: replace for-loop by comment output
This commit is contained in:
@@ -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);
|
||||||
|
Reference in New Issue
Block a user