template<typename _Fty> inline
void split(const std::string& s, const char* delims, _Fty op)
{
size_t start = 0;
size_t last = s.find_first_of(delims, start);
while (last != std::string::npos)
{
if (last > start)
op(s.substr(start, last - start));
last = s.find_first_of(delims, start = last + 1);
}
if (start < s.size())
op(s.substr(start));
}
inline
void split(const std::string& s, const std::string& delims, std::vector<std::string>& values)
{
split(s, delims, [&values](std::string&& item) { values.push_back(std::move(item)); } );
}
int main(int, char**)
{
std::vector<std::string> values;
split("hello#@ffdsdf#@ffgfdg#@ gdsfd @ af#", "#", values);
return 0;
}