mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Make joinHumanReadable work for input iterators.
This commit is contained in:
parent
b30da8859a
commit
14e116c1d5
@ -49,27 +49,23 @@ std::string joinHumanReadable
|
|||||||
std::string const& _lastSeparator = ""
|
std::string const& _lastSeparator = ""
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
auto it = begin(_list);
|
auto const itEnd = end(_list);
|
||||||
auto itEnd = end(_list);
|
|
||||||
|
|
||||||
std::string result;
|
std::string result;
|
||||||
|
|
||||||
// append first string
|
for (auto it = begin(_list); it != itEnd; )
|
||||||
if (it != itEnd)
|
|
||||||
{
|
{
|
||||||
result += *it;
|
std::string element = *it;
|
||||||
|
bool first = (it == begin(_list));
|
||||||
++it;
|
++it;
|
||||||
}
|
if (!first)
|
||||||
|
{
|
||||||
for (;it != itEnd; ++it)
|
if (it == itEnd && !_lastSeparator.empty())
|
||||||
{
|
result += _lastSeparator; // last iteration
|
||||||
if ((std::next(it) == itEnd) && !_lastSeparator.empty())
|
else
|
||||||
result += _lastSeparator; // last iteration
|
result += _separator;
|
||||||
else
|
}
|
||||||
result += _separator;
|
result += std::move(element);
|
||||||
|
|
||||||
// append string
|
|
||||||
result += *it;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
Loading…
Reference in New Issue
Block a user