This commit is contained in:
chriseth
2019-05-08 13:29:11 +02:00
parent 5fb85a6118
commit b4d6f847b4
6 changed files with 237 additions and 91 deletions
+16
View File
@@ -74,6 +74,22 @@ std::string joinHumanReadable
return result;
}
/// Joins collection of strings just like joinHumanReadable, but prepends the separator
/// unless the collection is empty.
template<class T>
std::string joinHumanReadablePrefixed
(
T const& _list,
std::string const& _separator = ", ",
std::string const& _lastSeparator = ""
)
{
if (begin(_list) == end(_list))
return {};
else
return _separator + joinHumanReadable(_list, _separator, _lastSeparator);
}
/// Formats large numbers to be easily readable by humans.
/// Returns decimal representation for smaller numbers; hex for large numbers.
/// "Special" numbers, powers-of-two and powers-of-two minus 1, are returned in