>>108824363
this code is actually wrong, semantically it would appear that each lambda would be considered different "function" but i guess that is not the case. just make sure this function doesn't "own" the string.
auto split(const std::string &str, const char delimeter)
{
return [it = str.begin(), end = str.end(),
d = delimeter]() mutable -> std::optional<std::string> {
std::string acc;
while (it != end)
{
const auto c = *it++;
if (c == d)
{
if (acc.empty())
continue;
break;
}
acc += c;
}
if (acc.empty())
return std::nullopt;
return acc;
};
}