Commit f77c7091 authored by Dominik Charousset's avatar Dominik Charousset

Generalize split to work for string_view

parent 54c167f4
...@@ -39,8 +39,8 @@ inline std::string is_any_of(std::string arg) { ...@@ -39,8 +39,8 @@ inline std::string is_any_of(std::string arg) {
constexpr bool token_compress_on = false; constexpr bool token_compress_on = false;
template <class Container, class Delim> template <class Container, class Str, class Delim>
void split(Container& result, const std::string& str, const Delim& delims, void split(Container& result, const Str& str, const Delim& delims,
bool keep_all = true) { bool keep_all = true) {
size_t pos = 0; size_t pos = 0;
size_t prev = 0; size_t prev = 0;
...@@ -53,9 +53,8 @@ void split(Container& result, const std::string& str, const Delim& delims, ...@@ -53,9 +53,8 @@ void split(Container& result, const std::string& str, const Delim& delims,
} }
prev = pos + 1; prev = pos + 1;
} }
if (prev < str.size()) { if (prev < str.size())
result.push_back(str.substr(prev, std::string::npos)); result.push_back(str.substr(prev, std::string::npos));
}
} }
template <class Iterator> template <class Iterator>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment