Split returns empty last element

This commit is contained in:
badaix 2024-07-04 21:56:30 +02:00
parent ad6ab1ad3b
commit 15a3cf9680
2 changed files with 21 additions and 2 deletions

View file

@ -162,6 +162,10 @@ std::vector<std::string>& split(const std::string& s, char delim, std::vector<st
{
elems.push_back(item);
}
if (!s.empty() && (s.back() == delim))
elems.emplace_back("");
return elems;
}