Skip to content

Commit 41fa320

Browse files
committed
Add auxiliary vector formatting function
1 parent d645301 commit 41fa320

1 file changed

Lines changed: 19 additions & 0 deletions

File tree

include/openPMD/auxiliary/StringManip.hpp

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,5 +242,24 @@ namespace auxiliary
242242
});
243243
return std::forward<S>(s);
244244
}
245+
246+
template <typename Vec>
247+
auto format_vec(Vec const &v) -> std::string
248+
{
249+
if (v.empty())
250+
{
251+
return std::string();
252+
}
253+
auto it = v.begin();
254+
auto end = v.end();
255+
std::stringstream res;
256+
res << '[' << *it++;
257+
for (; it != end; ++it)
258+
{
259+
res << ", " << *it;
260+
}
261+
res << ']';
262+
return res.str();
263+
}
245264
} // namespace auxiliary
246265
} // namespace openPMD

0 commit comments

Comments
 (0)