Skip to content
Snippets Groups Projects
Commit ffe7c586 authored by fxk8y's avatar fxk8y :spider:
Browse files

ST: Fixing str split function (last element was missing if empty)

parent bc7cfe9f
No related branches found
No related tags found
No related merge requests found
......@@ -19,7 +19,7 @@ namespace SpiderLib {
namespace Util {
// Taken from: https://stackoverflow.com/a/27511119
// slightly modified by fxk8y
// modified by fxk8y
std::vector<std::string> split(const std::string& s, char delim) {
std::string item;
......@@ -31,6 +31,9 @@ namespace SpiderLib {
// out.push_back(std::move(item)); // if C++11 (based on comment from @mchiasson)
}
// mod by fxk8y: fix missing last item if string ends with delim
if (s.back() == delim) out.push_back("");
return out;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment